Submission #965331

# Submission time Handle Problem Language Result Execution time Memory
965331 2024-04-18T10:37:42 Z pcc Cell Automaton (JOI23_cell) C++17
16 / 100
142 ms 57236 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,sse4")

#define pii pair<int,int>
#define fs first
#define sc second

const int mxn = 6010;
const int sh = mxn>>1;
int N,Q;
int req[mxn];
pii dir[] = {{-1,0},{1,0},{0,1},{0,-1}};
vector<pii> v;
vector<pii> vv;
int arr[mxn][mxn];
int ans = 0;

void move(){
	ans = 0;
	vv.clear();
	for(auto &i:v){
		for(auto &d:dir){
			if(!arr[i.fs+d.fs][i.sc+d.sc]){
				arr[i.fs+d.fs][i.sc+d.sc] = true;
				vv.push_back(pii(i.fs+d.fs,i.sc+d.sc));
				ans++;
			}
		}
	}
	vv.swap(v);
	return;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N>>Q;
	for(int i = 0;i<N;i++){
		int r,c;
		cin>>r>>c;
		arr[r+sh][c+sh] = 1;
		v.push_back(pii(r+sh,c+sh));
	}
	ans = v.size();
	int t = 0;
	while(Q--){
		int k;
		cin>>k;
		while(t<k){
			t++;
			move();
		}
		cout<<ans<<'\n';
		/*
		for(auto &i:arr){
			for(auto &j:i)cout<<j;cout<<endl;
		}cout<<endl;
	   */
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4732 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 1 ms 4696 KB Output is correct
13 Correct 2 ms 4704 KB Output is correct
14 Correct 1 ms 4700 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4732 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 1 ms 4696 KB Output is correct
13 Correct 2 ms 4704 KB Output is correct
14 Correct 1 ms 4700 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 45 ms 17756 KB Output is correct
30 Correct 73 ms 25324 KB Output is correct
31 Correct 110 ms 36128 KB Output is correct
32 Correct 129 ms 57236 KB Output is correct
33 Correct 58 ms 30544 KB Output is correct
34 Correct 63 ms 41160 KB Output is correct
35 Correct 67 ms 41564 KB Output is correct
36 Correct 7 ms 7772 KB Output is correct
37 Correct 7 ms 7772 KB Output is correct
38 Correct 116 ms 48704 KB Output is correct
39 Correct 115 ms 50500 KB Output is correct
40 Correct 142 ms 56268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 50780 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 50780 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4732 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 1 ms 4696 KB Output is correct
13 Correct 2 ms 4704 KB Output is correct
14 Correct 1 ms 4700 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 45 ms 17756 KB Output is correct
30 Correct 73 ms 25324 KB Output is correct
31 Correct 110 ms 36128 KB Output is correct
32 Correct 129 ms 57236 KB Output is correct
33 Correct 58 ms 30544 KB Output is correct
34 Correct 63 ms 41160 KB Output is correct
35 Correct 67 ms 41564 KB Output is correct
36 Correct 7 ms 7772 KB Output is correct
37 Correct 7 ms 7772 KB Output is correct
38 Correct 116 ms 48704 KB Output is correct
39 Correct 115 ms 50500 KB Output is correct
40 Correct 142 ms 56268 KB Output is correct
41 Runtime error 3 ms 604 KB Execution killed with signal 11
42 Halted 0 ms 0 KB -