#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define dot cerr << "passed" << '\n';
#define debug(x) cerr << "debug : " << #x << " = " << x << '\n';
ll N, Q;
pair<ll, ll> A[100007];
struct query {
ll t, id;
};
query Queries[500007];
ll ans[500007];
namespace subtask1 {
ll Cnt[57], cell[2][507][507];
const ll offset = 157;
void solve() {
for(int i = 1; i <= N; ++i) {
cell[0][A[i].fi + offset][A[i].se + offset] = 1;
}
auto fill = [&](ll p, ll a, ll b, ll c, ll d) {
if (cell[p][c][d] == -1) return; // grey can't fill
if (cell[p][c][d] == 1) return; // black can't fill
cell[(p + 1) % 2][c][d] = 1; // white near black -> fill
};
// dot;
for(int tm = 0; tm <= 500; ++tm) { // tm fix
memset(cell[(tm + 1) % 2], 0, sizeof(cell[(tm + 1) % 2]));
for(int i = 1; i <= 500; ++i) {
for(int j = 1; j <= 500; ++j) {
// 1 : black
// -1 : grey
// 0 : white
if (cell[tm % 2][i][j] == 1) {
Cnt[tm]++;
fill(tm % 2, i, j, i - 1, j);
fill(tm % 2, i, j, i, j - 1);
fill(tm % 2, i, j, i + 1, j);
fill(tm % 2, i, j, i, j + 1);
cell[(tm + 1) % 2][i][j] = -1; // its grey now
}
}
}
// cerr << "print table " << '\n';
// for(int i = -5 + offset; i <= 5 + offset; ++i) {
// for(int j = -5 + offset; j <= 5 + offset; ++j) {
// if (cell[tm % 2][i][j] == -1) cerr << 2;
// else cerr << cell[tm % 2][i][j];
// }
// cerr << '\n';
// }
// cerr << '\n';
}
for(int i = 1; i <= Q; ++i) {
// cerr << "query " << i << '\n';
cout << Cnt[Queries[i].t] << '\n';
}
}
void process() {
solve();
}
}
int main() {
ios_base :: sync_with_stdio(0);
cin.tie(0); cout.tie(0); cerr.tie(0);
if (fopen("FILE.INP", "r")) {
freopen("FILE.INP", "r", stdin);
freopen("FILE.OUT", "w", stdout);
}
cin >> N >> Q;
for(int i = 1; i <= N; ++i) cin >> A[i].fi >> A[i].se;
for(int i = 1; i <= Q; ++i) {
cin >> Queries[i].t;
Queries[i].id = i;
}
subtask1 :: process();
}
Compilation message
cell.cpp: In function 'int main()':
cell.cpp:73:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
73 | freopen("FILE.INP", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
cell.cpp:74:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
74 | freopen("FILE.OUT", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
8788 KB |
Output is correct |
2 |
Correct |
66 ms |
8956 KB |
Output is correct |
3 |
Correct |
70 ms |
8788 KB |
Output is correct |
4 |
Correct |
70 ms |
8788 KB |
Output is correct |
5 |
Correct |
80 ms |
8788 KB |
Output is correct |
6 |
Correct |
73 ms |
8788 KB |
Output is correct |
7 |
Correct |
71 ms |
8952 KB |
Output is correct |
8 |
Correct |
69 ms |
8788 KB |
Output is correct |
9 |
Correct |
68 ms |
8788 KB |
Output is correct |
10 |
Correct |
67 ms |
8788 KB |
Output is correct |
11 |
Correct |
69 ms |
8788 KB |
Output is correct |
12 |
Correct |
67 ms |
8788 KB |
Output is correct |
13 |
Correct |
70 ms |
8788 KB |
Output is correct |
14 |
Correct |
69 ms |
8952 KB |
Output is correct |
15 |
Correct |
67 ms |
8788 KB |
Output is correct |
16 |
Correct |
66 ms |
8788 KB |
Output is correct |
17 |
Correct |
69 ms |
8788 KB |
Output is correct |
18 |
Correct |
80 ms |
8788 KB |
Output is correct |
19 |
Correct |
70 ms |
8788 KB |
Output is correct |
20 |
Correct |
69 ms |
8788 KB |
Output is correct |
21 |
Correct |
68 ms |
8788 KB |
Output is correct |
22 |
Correct |
71 ms |
8952 KB |
Output is correct |
23 |
Correct |
69 ms |
8788 KB |
Output is correct |
24 |
Correct |
76 ms |
8952 KB |
Output is correct |
25 |
Correct |
74 ms |
8788 KB |
Output is correct |
26 |
Correct |
69 ms |
8952 KB |
Output is correct |
27 |
Correct |
72 ms |
8788 KB |
Output is correct |
28 |
Correct |
68 ms |
8848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
8788 KB |
Output is correct |
2 |
Correct |
66 ms |
8956 KB |
Output is correct |
3 |
Correct |
70 ms |
8788 KB |
Output is correct |
4 |
Correct |
70 ms |
8788 KB |
Output is correct |
5 |
Correct |
80 ms |
8788 KB |
Output is correct |
6 |
Correct |
73 ms |
8788 KB |
Output is correct |
7 |
Correct |
71 ms |
8952 KB |
Output is correct |
8 |
Correct |
69 ms |
8788 KB |
Output is correct |
9 |
Correct |
68 ms |
8788 KB |
Output is correct |
10 |
Correct |
67 ms |
8788 KB |
Output is correct |
11 |
Correct |
69 ms |
8788 KB |
Output is correct |
12 |
Correct |
67 ms |
8788 KB |
Output is correct |
13 |
Correct |
70 ms |
8788 KB |
Output is correct |
14 |
Correct |
69 ms |
8952 KB |
Output is correct |
15 |
Correct |
67 ms |
8788 KB |
Output is correct |
16 |
Correct |
66 ms |
8788 KB |
Output is correct |
17 |
Correct |
69 ms |
8788 KB |
Output is correct |
18 |
Correct |
80 ms |
8788 KB |
Output is correct |
19 |
Correct |
70 ms |
8788 KB |
Output is correct |
20 |
Correct |
69 ms |
8788 KB |
Output is correct |
21 |
Correct |
68 ms |
8788 KB |
Output is correct |
22 |
Correct |
71 ms |
8952 KB |
Output is correct |
23 |
Correct |
69 ms |
8788 KB |
Output is correct |
24 |
Correct |
76 ms |
8952 KB |
Output is correct |
25 |
Correct |
74 ms |
8788 KB |
Output is correct |
26 |
Correct |
69 ms |
8952 KB |
Output is correct |
27 |
Correct |
72 ms |
8788 KB |
Output is correct |
28 |
Correct |
68 ms |
8848 KB |
Output is correct |
29 |
Incorrect |
68 ms |
8852 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
25 ms |
12372 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
25 ms |
12372 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
89 ms |
25932 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
89 ms |
25932 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
8788 KB |
Output is correct |
2 |
Correct |
66 ms |
8956 KB |
Output is correct |
3 |
Correct |
70 ms |
8788 KB |
Output is correct |
4 |
Correct |
70 ms |
8788 KB |
Output is correct |
5 |
Correct |
80 ms |
8788 KB |
Output is correct |
6 |
Correct |
73 ms |
8788 KB |
Output is correct |
7 |
Correct |
71 ms |
8952 KB |
Output is correct |
8 |
Correct |
69 ms |
8788 KB |
Output is correct |
9 |
Correct |
68 ms |
8788 KB |
Output is correct |
10 |
Correct |
67 ms |
8788 KB |
Output is correct |
11 |
Correct |
69 ms |
8788 KB |
Output is correct |
12 |
Correct |
67 ms |
8788 KB |
Output is correct |
13 |
Correct |
70 ms |
8788 KB |
Output is correct |
14 |
Correct |
69 ms |
8952 KB |
Output is correct |
15 |
Correct |
67 ms |
8788 KB |
Output is correct |
16 |
Correct |
66 ms |
8788 KB |
Output is correct |
17 |
Correct |
69 ms |
8788 KB |
Output is correct |
18 |
Correct |
80 ms |
8788 KB |
Output is correct |
19 |
Correct |
70 ms |
8788 KB |
Output is correct |
20 |
Correct |
69 ms |
8788 KB |
Output is correct |
21 |
Correct |
68 ms |
8788 KB |
Output is correct |
22 |
Correct |
71 ms |
8952 KB |
Output is correct |
23 |
Correct |
69 ms |
8788 KB |
Output is correct |
24 |
Correct |
76 ms |
8952 KB |
Output is correct |
25 |
Correct |
74 ms |
8788 KB |
Output is correct |
26 |
Correct |
69 ms |
8952 KB |
Output is correct |
27 |
Correct |
72 ms |
8788 KB |
Output is correct |
28 |
Correct |
68 ms |
8848 KB |
Output is correct |
29 |
Incorrect |
68 ms |
8852 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |