Submission #00018


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef vector<int> Vi;
typedef pair<int,int> Pii;
typedef pair<int,Pii> Pip;
const int INF = (1<<30);
const int dx[]={0,1,1,1,0,-1,-1,-1},dy[]={-1,-1,0,1,1,1,0,-1};
int main(){
int w, h, n, m;
int data[1000][1000];
int ans = 0;
cin >> w >> h >> n;
for(int i=0; i<h; i++) {
for(int j=0; j<w; j++) {
data[i][j] = -1;
}
}
for(int i=0; i<n; i++) {
int a, b, c;
cin >> a >> b >> c;
a--; b--;
data[b][a] = c;
}
/*for(int i=0; i<h; i++) {
for(int j=0; j<w; j++) {
if( data[i][j] >= 0 ) {
ans++;
}
cout << data[i][j] << ' ';
}
cout << endl;
}*/
cin >> m;
for(int i=0; i<m; i++) {
int a, b, c, x, y, c_=0;
cin >> a >> b >> c;
a--; b--;
data[b][a] -= c;
/*for(int j=0; j<8; j++) {
x = a; y = b; c_ = c;
while(1) {
int nx = x+dx[j], ny = y+dy[j];
c_--;
if( nx < 0 || ny < 0 || nx >= w || ny >= h || c_==0 ) {
break;
}
else {
data[ny][nx] -= c_;
}
}
}:*/
c_ = c;
while(c_) {
c_--;
for(int j=b-(c-c_); j<=b+(c-c_); j++) {
for(int k=a-(c-c_); k<=a+(c-c_); k++) {
if( j < 0 || k < 0 || j >= h || k >= w || (abs(j-b) != (c-c_) && abs(k-a) != (c-c_))) {
continue;
}
else {
data[j][k] -= c_;
}
}
}
}
}
ans =0;
for(int i=0; i<h; i++) {
for(int j=0; j<w; j++) {
if( data[i][j]+1 > 0 ) ans++;
}
}
if( !ans ) cout << "oh..." << endl;
else cout << ans << endl;
}

ステータス

項目 データ
問題 0001 - 地震予測
ユーザー名 ei1430
投稿日時 2015-10-28 17:15:33
言語 C++11
状態 Time Limit Exceeded
得点 0
ソースコード長 1667 Byte
最大実行時間 1000 ms
最大メモリ使用量 4212 KB

セット

セット 得点 Cases
1 ALL 0 / 100 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
toi01_in1.txt AC 11 ms 476 KB
1
toi01_in2.txt AC 14 ms 376 KB
1
toi01_in3.txt AC 13 ms 440 KB
1
toi01_in4.txt AC 15 ms 524 KB
1
toi01_in5.txt AC 13 ms 620 KB
1
toi01_in6.txt AC 17 ms 912 KB
1
toi01_in7.txt AC 893 ms 4212 KB
1
toi01_in9.txt TLE 1000 ms 1016 KB
1
toi01_in12.txt AC 14 ms 428 KB
1