#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define vo vector
#define fi first
#define se second
#define pr(x) cerr << #x << " " << x << endl;
#define sz(x) x.size()
typedef vo<int> vi;
typedef pair<int, int> pii;
#define rep(i, a, b) for(ll i = (a); i<(b); i++)
ll const inf = LLONG_MAX, mxn = 51;
int n, q, ans[mxn];
map<pii, int> coordinatesOdd; //coordinate to color black, grey, white
map<pii, int> coordinatesEven;
int dir[4][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}} ;
void solve(int t, map<pii, int> &coordinates, map<pii, int> &other){
other.clear();
for(auto c: coordinates){
int col = c.se;
if(col == 1){
ans[t]++;
other[c.fi] = 2;
for(auto x: dir){
ll nr = x[0] + c.fi.fi, nc = x[1] + c.fi.se;
if(!coordinates.count({nr, nc})){
other[{nr, nc}] = 1;
}
}
}
}
}
signed main(){
cin>>n>>q;
rep(i, 0, n){
int ri, ci;
cin>>ri>>ci;
coordinatesEven[{ri, ci}] = 1;
}
rep(t, 0, 50){
if(t%2==0){
solve(t, coordinatesEven, coordinatesOdd);
}
else{
solve(t, coordinatesOdd, coordinatesEven);
}
}
rep(i, 0, q){
int ti; cin>>ti;
cout << ans[ti] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
5 ms |
344 KB |
Output is correct |
3 |
Correct |
11 ms |
344 KB |
Output is correct |
4 |
Correct |
15 ms |
436 KB |
Output is correct |
5 |
Correct |
4 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
348 KB |
Output is correct |
8 |
Correct |
17 ms |
1704 KB |
Output is correct |
9 |
Correct |
13 ms |
600 KB |
Output is correct |
10 |
Correct |
13 ms |
604 KB |
Output is correct |
11 |
Correct |
14 ms |
604 KB |
Output is correct |
12 |
Correct |
17 ms |
1120 KB |
Output is correct |
13 |
Correct |
17 ms |
1204 KB |
Output is correct |
14 |
Correct |
21 ms |
1228 KB |
Output is correct |
15 |
Correct |
21 ms |
1236 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
2 ms |
344 KB |
Output is correct |
24 |
Correct |
3 ms |
500 KB |
Output is correct |
25 |
Correct |
2 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
348 KB |
Output is correct |
28 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
5 ms |
344 KB |
Output is correct |
3 |
Correct |
11 ms |
344 KB |
Output is correct |
4 |
Correct |
15 ms |
436 KB |
Output is correct |
5 |
Correct |
4 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
348 KB |
Output is correct |
8 |
Correct |
17 ms |
1704 KB |
Output is correct |
9 |
Correct |
13 ms |
600 KB |
Output is correct |
10 |
Correct |
13 ms |
604 KB |
Output is correct |
11 |
Correct |
14 ms |
604 KB |
Output is correct |
12 |
Correct |
17 ms |
1120 KB |
Output is correct |
13 |
Correct |
17 ms |
1204 KB |
Output is correct |
14 |
Correct |
21 ms |
1228 KB |
Output is correct |
15 |
Correct |
21 ms |
1236 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
2 ms |
344 KB |
Output is correct |
24 |
Correct |
3 ms |
500 KB |
Output is correct |
25 |
Correct |
2 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
348 KB |
Output is correct |
28 |
Correct |
3 ms |
504 KB |
Output is correct |
29 |
Incorrect |
5 ms |
348 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
8077 ms |
703588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
8077 ms |
703588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
104 ms |
2644 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
104 ms |
2644 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
5 ms |
344 KB |
Output is correct |
3 |
Correct |
11 ms |
344 KB |
Output is correct |
4 |
Correct |
15 ms |
436 KB |
Output is correct |
5 |
Correct |
4 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
348 KB |
Output is correct |
8 |
Correct |
17 ms |
1704 KB |
Output is correct |
9 |
Correct |
13 ms |
600 KB |
Output is correct |
10 |
Correct |
13 ms |
604 KB |
Output is correct |
11 |
Correct |
14 ms |
604 KB |
Output is correct |
12 |
Correct |
17 ms |
1120 KB |
Output is correct |
13 |
Correct |
17 ms |
1204 KB |
Output is correct |
14 |
Correct |
21 ms |
1228 KB |
Output is correct |
15 |
Correct |
21 ms |
1236 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
2 ms |
344 KB |
Output is correct |
24 |
Correct |
3 ms |
500 KB |
Output is correct |
25 |
Correct |
2 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
348 KB |
Output is correct |
28 |
Correct |
3 ms |
504 KB |
Output is correct |
29 |
Incorrect |
5 ms |
348 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |