Submission #975125

# Submission time Handle Problem Language Result Execution time Memory
975125 2024-05-04T13:20:41 Z oolimry Mars (APIO22_mars) C++17
54 / 100
371 ms 5664 KB
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define showlist(x) cerr << #x << " is "; for(auto p : x) cerr << p << " "; cerr << endl;
typedef pair<int,int> ii;
 
///attempt 3: push all 3x3 info up so u can store 900
/// stuff for dfs
int grid[45][45];

void dfs(int i, int j){
	if(i < 0 or j < 0) return;
	if(grid[i][j] == 0) return;
	
	grid[i][j] = 0;
	
	dfs(i+1,j);
	dfs(i-1,j);
	dfs(i,j+1);
	dfs(i,j-1);
}

int cellToBit(int i, int j){
	return (i/2) * 10 + (j/2);
}

void orTo(string &a, string b){
	for(int p = 0;p < 100;p++){
		if(b[p] == '1') a[p] = '1';
	}
}

int n, K;
const int SQ = 10;
int group(int i, int j, int k){
	int sqsize = (2 + 2*n+1 - 2*k) / 3;
	int G = (i / sqsize) * 10 + j / sqsize;
	return G;
}
 
 
string process(vector <vector<string>> a, int I, int J, int K, int _n){
	n = _n;
	//cerr << I << " " << J << " " << K << endl;				
	
	string res = string(100 ,'0');
	
	if(K == 0){ ///first run
		for(int i = 0;i <= 2;i++){
			for(int j = 0;j <= 2;j++){
				//show3(i,j,a[i][j]);
				if(a[i][j][0] == '1'){
					a[i][j] = string(100, '0');
					a[i][j][((i+I)%SQ) * 10 + ((j+J)%SQ)] = '1';
					//show(((i+I)%SQ) * 10 + ((j+J)%SQ));
				}
				else a[i][j] = string(100, '0');
			}
		}
	}
	
	if(K < n-1){
		for(int i = 0;i <= 2;i++){
			for(int j = 0;j <= 2;j++){
				//show2(i,j);
				//show2(group(I,J,K+1),group(i+I, j+J, K));
				if(group(I,J,K+1) == group(i+I, j+J, K)){
					orTo(res, a[i][j]);
				} 
			}
		}
	}
	
	else if(K == n-1){ ///last phase --> convert to binary 
		for(int i = 0;i < 45;i++) for(int j = 0;j < 45;j++) grid[i][j] = 0;
		
		for(int io = 0;io <= 2;io += 1){
			for(int jo = 0;jo <= 2;jo += 1){
				for(int p = 0;p < 100;p++){
					if(a[io][jo][p] == '1'){
						
						int groupno = group(io,jo,K);
						
						for(int i = 0;i <= 2*n;i++){
							for(int j = 0;j <= 2*n;j++){
								int P = ((i)%SQ) * 10 + ((j)%SQ);
								if(groupno == group(i,j,0) and p == P){
									grid[i][j] = 1;
									
									//show2(i,j);
								}
							}
						}
					}
				}
			}
		}
		
		
		for(int i = 0;i < 2*n+1;i++){
			for(int j = 0;j < 2*n+1;j++) cerr << grid[i][j];
			cerr << endl;
		}
		
		///count no. of connected components via dfs
		int cnt = 0; 
		for(int i = 0;i < 45;i++) for(int j = 0;j < 45;j++){
			if(grid[i][j]){
				cnt++;
				dfs(i,j);
			}
		}
		
		//cerr << cnt << endl;
 
		res = string(100 ,'0');
		for(int p = 0;p < 100;p++){
			if(cnt % 2 == 1) res[p] = '1';
			cnt /= 2;
		}
	}
	
	//cerr << res << endl;
	
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4416 KB Output is correct
2 Correct 4 ms 4208 KB Output is correct
3 Correct 7 ms 3716 KB Output is correct
4 Correct 7 ms 4280 KB Output is correct
5 Correct 8 ms 4184 KB Output is correct
6 Correct 7 ms 4632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4416 KB Output is correct
2 Correct 4 ms 4208 KB Output is correct
3 Correct 7 ms 3716 KB Output is correct
4 Correct 7 ms 4280 KB Output is correct
5 Correct 8 ms 4184 KB Output is correct
6 Correct 7 ms 4632 KB Output is correct
7 Correct 8 ms 4308 KB Output is correct
8 Correct 12 ms 3956 KB Output is correct
9 Correct 11 ms 3716 KB Output is correct
10 Correct 9 ms 3904 KB Output is correct
11 Correct 12 ms 4156 KB Output is correct
12 Correct 10 ms 4496 KB Output is correct
13 Correct 11 ms 3960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4416 KB Output is correct
2 Correct 4 ms 4208 KB Output is correct
3 Correct 7 ms 3716 KB Output is correct
4 Correct 7 ms 4280 KB Output is correct
5 Correct 8 ms 4184 KB Output is correct
6 Correct 7 ms 4632 KB Output is correct
7 Correct 8 ms 4308 KB Output is correct
8 Correct 12 ms 3956 KB Output is correct
9 Correct 11 ms 3716 KB Output is correct
10 Correct 9 ms 3904 KB Output is correct
11 Correct 12 ms 4156 KB Output is correct
12 Correct 10 ms 4496 KB Output is correct
13 Correct 11 ms 3960 KB Output is correct
14 Correct 22 ms 4036 KB Output is correct
15 Correct 33 ms 4232 KB Output is correct
16 Correct 30 ms 4304 KB Output is correct
17 Correct 30 ms 3768 KB Output is correct
18 Correct 31 ms 4420 KB Output is correct
19 Correct 31 ms 4128 KB Output is correct
20 Correct 29 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4416 KB Output is correct
2 Correct 4 ms 4208 KB Output is correct
3 Correct 7 ms 3716 KB Output is correct
4 Correct 7 ms 4280 KB Output is correct
5 Correct 8 ms 4184 KB Output is correct
6 Correct 7 ms 4632 KB Output is correct
7 Correct 8 ms 4308 KB Output is correct
8 Correct 12 ms 3956 KB Output is correct
9 Correct 11 ms 3716 KB Output is correct
10 Correct 9 ms 3904 KB Output is correct
11 Correct 12 ms 4156 KB Output is correct
12 Correct 10 ms 4496 KB Output is correct
13 Correct 11 ms 3960 KB Output is correct
14 Correct 22 ms 4036 KB Output is correct
15 Correct 33 ms 4232 KB Output is correct
16 Correct 30 ms 4304 KB Output is correct
17 Correct 30 ms 3768 KB Output is correct
18 Correct 31 ms 4420 KB Output is correct
19 Correct 31 ms 4128 KB Output is correct
20 Correct 29 ms 4180 KB Output is correct
21 Correct 43 ms 4400 KB Output is correct
22 Correct 67 ms 4324 KB Output is correct
23 Correct 69 ms 4436 KB Output is correct
24 Correct 71 ms 4424 KB Output is correct
25 Correct 68 ms 4260 KB Output is correct
26 Correct 71 ms 3884 KB Output is correct
27 Correct 65 ms 4104 KB Output is correct
28 Correct 65 ms 4284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4416 KB Output is correct
2 Correct 4 ms 4208 KB Output is correct
3 Correct 7 ms 3716 KB Output is correct
4 Correct 7 ms 4280 KB Output is correct
5 Correct 8 ms 4184 KB Output is correct
6 Correct 7 ms 4632 KB Output is correct
7 Correct 8 ms 4308 KB Output is correct
8 Correct 12 ms 3956 KB Output is correct
9 Correct 11 ms 3716 KB Output is correct
10 Correct 9 ms 3904 KB Output is correct
11 Correct 12 ms 4156 KB Output is correct
12 Correct 10 ms 4496 KB Output is correct
13 Correct 11 ms 3960 KB Output is correct
14 Correct 22 ms 4036 KB Output is correct
15 Correct 33 ms 4232 KB Output is correct
16 Correct 30 ms 4304 KB Output is correct
17 Correct 30 ms 3768 KB Output is correct
18 Correct 31 ms 4420 KB Output is correct
19 Correct 31 ms 4128 KB Output is correct
20 Correct 29 ms 4180 KB Output is correct
21 Correct 43 ms 4400 KB Output is correct
22 Correct 67 ms 4324 KB Output is correct
23 Correct 69 ms 4436 KB Output is correct
24 Correct 71 ms 4424 KB Output is correct
25 Correct 68 ms 4260 KB Output is correct
26 Correct 71 ms 3884 KB Output is correct
27 Correct 65 ms 4104 KB Output is correct
28 Correct 65 ms 4284 KB Output is correct
29 Correct 94 ms 4456 KB Output is correct
30 Correct 136 ms 4744 KB Output is correct
31 Correct 136 ms 4416 KB Output is correct
32 Correct 129 ms 4380 KB Output is correct
33 Correct 136 ms 4704 KB Output is correct
34 Correct 124 ms 4108 KB Output is correct
35 Correct 135 ms 4952 KB Output is correct
36 Correct 131 ms 4612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4416 KB Output is correct
2 Correct 4 ms 4208 KB Output is correct
3 Correct 7 ms 3716 KB Output is correct
4 Correct 7 ms 4280 KB Output is correct
5 Correct 8 ms 4184 KB Output is correct
6 Correct 7 ms 4632 KB Output is correct
7 Correct 8 ms 4308 KB Output is correct
8 Correct 12 ms 3956 KB Output is correct
9 Correct 11 ms 3716 KB Output is correct
10 Correct 9 ms 3904 KB Output is correct
11 Correct 12 ms 4156 KB Output is correct
12 Correct 10 ms 4496 KB Output is correct
13 Correct 11 ms 3960 KB Output is correct
14 Correct 22 ms 4036 KB Output is correct
15 Correct 33 ms 4232 KB Output is correct
16 Correct 30 ms 4304 KB Output is correct
17 Correct 30 ms 3768 KB Output is correct
18 Correct 31 ms 4420 KB Output is correct
19 Correct 31 ms 4128 KB Output is correct
20 Correct 29 ms 4180 KB Output is correct
21 Correct 43 ms 4400 KB Output is correct
22 Correct 67 ms 4324 KB Output is correct
23 Correct 69 ms 4436 KB Output is correct
24 Correct 71 ms 4424 KB Output is correct
25 Correct 68 ms 4260 KB Output is correct
26 Correct 71 ms 3884 KB Output is correct
27 Correct 65 ms 4104 KB Output is correct
28 Correct 65 ms 4284 KB Output is correct
29 Correct 94 ms 4456 KB Output is correct
30 Correct 136 ms 4744 KB Output is correct
31 Correct 136 ms 4416 KB Output is correct
32 Correct 129 ms 4380 KB Output is correct
33 Correct 136 ms 4704 KB Output is correct
34 Correct 124 ms 4108 KB Output is correct
35 Correct 135 ms 4952 KB Output is correct
36 Correct 131 ms 4612 KB Output is correct
37 Correct 173 ms 4664 KB Output is correct
38 Correct 220 ms 4384 KB Output is correct
39 Correct 230 ms 4276 KB Output is correct
40 Correct 237 ms 4964 KB Output is correct
41 Correct 238 ms 5128 KB Output is correct
42 Correct 222 ms 5496 KB Output is correct
43 Correct 224 ms 4628 KB Output is correct
44 Correct 223 ms 5104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4416 KB Output is correct
2 Correct 4 ms 4208 KB Output is correct
3 Correct 7 ms 3716 KB Output is correct
4 Correct 7 ms 4280 KB Output is correct
5 Correct 8 ms 4184 KB Output is correct
6 Correct 7 ms 4632 KB Output is correct
7 Correct 8 ms 4308 KB Output is correct
8 Correct 12 ms 3956 KB Output is correct
9 Correct 11 ms 3716 KB Output is correct
10 Correct 9 ms 3904 KB Output is correct
11 Correct 12 ms 4156 KB Output is correct
12 Correct 10 ms 4496 KB Output is correct
13 Correct 11 ms 3960 KB Output is correct
14 Correct 22 ms 4036 KB Output is correct
15 Correct 33 ms 4232 KB Output is correct
16 Correct 30 ms 4304 KB Output is correct
17 Correct 30 ms 3768 KB Output is correct
18 Correct 31 ms 4420 KB Output is correct
19 Correct 31 ms 4128 KB Output is correct
20 Correct 29 ms 4180 KB Output is correct
21 Correct 43 ms 4400 KB Output is correct
22 Correct 67 ms 4324 KB Output is correct
23 Correct 69 ms 4436 KB Output is correct
24 Correct 71 ms 4424 KB Output is correct
25 Correct 68 ms 4260 KB Output is correct
26 Correct 71 ms 3884 KB Output is correct
27 Correct 65 ms 4104 KB Output is correct
28 Correct 65 ms 4284 KB Output is correct
29 Correct 94 ms 4456 KB Output is correct
30 Correct 136 ms 4744 KB Output is correct
31 Correct 136 ms 4416 KB Output is correct
32 Correct 129 ms 4380 KB Output is correct
33 Correct 136 ms 4704 KB Output is correct
34 Correct 124 ms 4108 KB Output is correct
35 Correct 135 ms 4952 KB Output is correct
36 Correct 131 ms 4612 KB Output is correct
37 Correct 173 ms 4664 KB Output is correct
38 Correct 220 ms 4384 KB Output is correct
39 Correct 230 ms 4276 KB Output is correct
40 Correct 237 ms 4964 KB Output is correct
41 Correct 238 ms 5128 KB Output is correct
42 Correct 222 ms 5496 KB Output is correct
43 Correct 224 ms 4628 KB Output is correct
44 Correct 223 ms 5104 KB Output is correct
45 Correct 292 ms 4780 KB Output is correct
46 Correct 353 ms 4880 KB Output is correct
47 Correct 359 ms 5228 KB Output is correct
48 Correct 357 ms 5080 KB Output is correct
49 Correct 366 ms 4652 KB Output is correct
50 Correct 350 ms 4944 KB Output is correct
51 Correct 369 ms 5560 KB Output is correct
52 Correct 364 ms 5272 KB Output is correct
53 Correct 371 ms 4812 KB Output is correct
54 Correct 364 ms 5664 KB Output is correct
55 Correct 355 ms 4868 KB Output is correct
56 Correct 347 ms 5108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4416 KB Output is correct
2 Correct 4 ms 4208 KB Output is correct
3 Correct 7 ms 3716 KB Output is correct
4 Correct 7 ms 4280 KB Output is correct
5 Correct 8 ms 4184 KB Output is correct
6 Correct 7 ms 4632 KB Output is correct
7 Correct 8 ms 4308 KB Output is correct
8 Correct 12 ms 3956 KB Output is correct
9 Correct 11 ms 3716 KB Output is correct
10 Correct 9 ms 3904 KB Output is correct
11 Correct 12 ms 4156 KB Output is correct
12 Correct 10 ms 4496 KB Output is correct
13 Correct 11 ms 3960 KB Output is correct
14 Correct 22 ms 4036 KB Output is correct
15 Correct 33 ms 4232 KB Output is correct
16 Correct 30 ms 4304 KB Output is correct
17 Correct 30 ms 3768 KB Output is correct
18 Correct 31 ms 4420 KB Output is correct
19 Correct 31 ms 4128 KB Output is correct
20 Correct 29 ms 4180 KB Output is correct
21 Correct 43 ms 4400 KB Output is correct
22 Correct 67 ms 4324 KB Output is correct
23 Correct 69 ms 4436 KB Output is correct
24 Correct 71 ms 4424 KB Output is correct
25 Correct 68 ms 4260 KB Output is correct
26 Correct 71 ms 3884 KB Output is correct
27 Correct 65 ms 4104 KB Output is correct
28 Correct 65 ms 4284 KB Output is correct
29 Correct 94 ms 4456 KB Output is correct
30 Correct 136 ms 4744 KB Output is correct
31 Correct 136 ms 4416 KB Output is correct
32 Correct 129 ms 4380 KB Output is correct
33 Correct 136 ms 4704 KB Output is correct
34 Correct 124 ms 4108 KB Output is correct
35 Correct 135 ms 4952 KB Output is correct
36 Correct 131 ms 4612 KB Output is correct
37 Correct 173 ms 4664 KB Output is correct
38 Correct 220 ms 4384 KB Output is correct
39 Correct 230 ms 4276 KB Output is correct
40 Correct 237 ms 4964 KB Output is correct
41 Correct 238 ms 5128 KB Output is correct
42 Correct 222 ms 5496 KB Output is correct
43 Correct 224 ms 4628 KB Output is correct
44 Correct 223 ms 5104 KB Output is correct
45 Correct 292 ms 4780 KB Output is correct
46 Correct 353 ms 4880 KB Output is correct
47 Correct 359 ms 5228 KB Output is correct
48 Correct 357 ms 5080 KB Output is correct
49 Correct 366 ms 4652 KB Output is correct
50 Correct 350 ms 4944 KB Output is correct
51 Correct 369 ms 5560 KB Output is correct
52 Correct 364 ms 5272 KB Output is correct
53 Correct 371 ms 4812 KB Output is correct
54 Correct 364 ms 5664 KB Output is correct
55 Correct 355 ms 4868 KB Output is correct
56 Correct 347 ms 5108 KB Output is correct
57 Incorrect 57 ms 592 KB Incorrect
58 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4416 KB Output is correct
2 Correct 4 ms 4208 KB Output is correct
3 Correct 7 ms 3716 KB Output is correct
4 Correct 7 ms 4280 KB Output is correct
5 Correct 8 ms 4184 KB Output is correct
6 Correct 7 ms 4632 KB Output is correct
7 Correct 8 ms 4308 KB Output is correct
8 Correct 12 ms 3956 KB Output is correct
9 Correct 11 ms 3716 KB Output is correct
10 Correct 9 ms 3904 KB Output is correct
11 Correct 12 ms 4156 KB Output is correct
12 Correct 10 ms 4496 KB Output is correct
13 Correct 11 ms 3960 KB Output is correct
14 Correct 22 ms 4036 KB Output is correct
15 Correct 33 ms 4232 KB Output is correct
16 Correct 30 ms 4304 KB Output is correct
17 Correct 30 ms 3768 KB Output is correct
18 Correct 31 ms 4420 KB Output is correct
19 Correct 31 ms 4128 KB Output is correct
20 Correct 29 ms 4180 KB Output is correct
21 Correct 43 ms 4400 KB Output is correct
22 Correct 67 ms 4324 KB Output is correct
23 Correct 69 ms 4436 KB Output is correct
24 Correct 71 ms 4424 KB Output is correct
25 Correct 68 ms 4260 KB Output is correct
26 Correct 71 ms 3884 KB Output is correct
27 Correct 65 ms 4104 KB Output is correct
28 Correct 65 ms 4284 KB Output is correct
29 Correct 94 ms 4456 KB Output is correct
30 Correct 136 ms 4744 KB Output is correct
31 Correct 136 ms 4416 KB Output is correct
32 Correct 129 ms 4380 KB Output is correct
33 Correct 136 ms 4704 KB Output is correct
34 Correct 124 ms 4108 KB Output is correct
35 Correct 135 ms 4952 KB Output is correct
36 Correct 131 ms 4612 KB Output is correct
37 Correct 173 ms 4664 KB Output is correct
38 Correct 220 ms 4384 KB Output is correct
39 Correct 230 ms 4276 KB Output is correct
40 Correct 237 ms 4964 KB Output is correct
41 Correct 238 ms 5128 KB Output is correct
42 Correct 222 ms 5496 KB Output is correct
43 Correct 224 ms 4628 KB Output is correct
44 Correct 223 ms 5104 KB Output is correct
45 Correct 292 ms 4780 KB Output is correct
46 Correct 353 ms 4880 KB Output is correct
47 Correct 359 ms 5228 KB Output is correct
48 Correct 357 ms 5080 KB Output is correct
49 Correct 366 ms 4652 KB Output is correct
50 Correct 350 ms 4944 KB Output is correct
51 Correct 369 ms 5560 KB Output is correct
52 Correct 364 ms 5272 KB Output is correct
53 Correct 371 ms 4812 KB Output is correct
54 Correct 364 ms 5664 KB Output is correct
55 Correct 355 ms 4868 KB Output is correct
56 Correct 347 ms 5108 KB Output is correct
57 Incorrect 57 ms 592 KB Incorrect
58 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4416 KB Output is correct
2 Correct 4 ms 4208 KB Output is correct
3 Correct 7 ms 3716 KB Output is correct
4 Correct 7 ms 4280 KB Output is correct
5 Correct 8 ms 4184 KB Output is correct
6 Correct 7 ms 4632 KB Output is correct
7 Correct 8 ms 4308 KB Output is correct
8 Correct 12 ms 3956 KB Output is correct
9 Correct 11 ms 3716 KB Output is correct
10 Correct 9 ms 3904 KB Output is correct
11 Correct 12 ms 4156 KB Output is correct
12 Correct 10 ms 4496 KB Output is correct
13 Correct 11 ms 3960 KB Output is correct
14 Correct 22 ms 4036 KB Output is correct
15 Correct 33 ms 4232 KB Output is correct
16 Correct 30 ms 4304 KB Output is correct
17 Correct 30 ms 3768 KB Output is correct
18 Correct 31 ms 4420 KB Output is correct
19 Correct 31 ms 4128 KB Output is correct
20 Correct 29 ms 4180 KB Output is correct
21 Correct 43 ms 4400 KB Output is correct
22 Correct 67 ms 4324 KB Output is correct
23 Correct 69 ms 4436 KB Output is correct
24 Correct 71 ms 4424 KB Output is correct
25 Correct 68 ms 4260 KB Output is correct
26 Correct 71 ms 3884 KB Output is correct
27 Correct 65 ms 4104 KB Output is correct
28 Correct 65 ms 4284 KB Output is correct
29 Correct 94 ms 4456 KB Output is correct
30 Correct 136 ms 4744 KB Output is correct
31 Correct 136 ms 4416 KB Output is correct
32 Correct 129 ms 4380 KB Output is correct
33 Correct 136 ms 4704 KB Output is correct
34 Correct 124 ms 4108 KB Output is correct
35 Correct 135 ms 4952 KB Output is correct
36 Correct 131 ms 4612 KB Output is correct
37 Correct 173 ms 4664 KB Output is correct
38 Correct 220 ms 4384 KB Output is correct
39 Correct 230 ms 4276 KB Output is correct
40 Correct 237 ms 4964 KB Output is correct
41 Correct 238 ms 5128 KB Output is correct
42 Correct 222 ms 5496 KB Output is correct
43 Correct 224 ms 4628 KB Output is correct
44 Correct 223 ms 5104 KB Output is correct
45 Correct 292 ms 4780 KB Output is correct
46 Correct 353 ms 4880 KB Output is correct
47 Correct 359 ms 5228 KB Output is correct
48 Correct 357 ms 5080 KB Output is correct
49 Correct 366 ms 4652 KB Output is correct
50 Correct 350 ms 4944 KB Output is correct
51 Correct 369 ms 5560 KB Output is correct
52 Correct 364 ms 5272 KB Output is correct
53 Correct 371 ms 4812 KB Output is correct
54 Correct 364 ms 5664 KB Output is correct
55 Correct 355 ms 4868 KB Output is correct
56 Correct 347 ms 5108 KB Output is correct
57 Incorrect 57 ms 592 KB Incorrect
58 Halted 0 ms 0 KB -