Submission #733561

# Submission time Handle Problem Language Result Execution time Memory
733561 2023-05-01T03:29:46 Z minhcool Mars (APIO22_mars) C++17
36 / 100
1056 ms 36016 KB
#include "mars.h"
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
 
const int N = 35;
 
const int oo = 1e18 + 7, mod = 1e9 + 7;
 
vector<ii> route[N][N][N];
int cnt[N][N][N][N];
ii save[N][N][N][N][105];// cell (i, j) at phase k, the h-th bit will save the value of what node
 
void prep(int id){// preparing the route for (i, j)
	// in order to get 36, we don't need the SA the path
	int n = id;
	for(int i = 0; i < (2 * n + 1); i++){
		for(int j = 0; j < (2 * n + 1); j++){
			route[id][i][j].clear();
			for(int k = 0; k < (2 * n + 1); k++) cnt[id][i][j][k] = 0;
		}
	}
	for(int i = 0; i < (2 * n + 1); i++){
		for(int j = 0; j < (2 * n + 1); j++){
			for(int k = 0; k < n; k++){
				route[id][i][j].pb({i - 2 * max(0, min(k, (i - 1) / 2)), j - 2 * max(0, min(k, (j - 1) / 2))});
			}
			int itr = 0;
			for(auto it : route[id][i][j]){
				//cout << i << " " << j << " " << it.fi << " " << it.se << " " << itr << "\n";
				save[id][it.fi][it.se][itr][cnt[id][it.fi][it.se][itr]] = {i, j};
				cnt[id][it.fi][it.se][itr]++;
				itr++;
			}
		}	
	}
	for(int i = 0; i <= 2 * n; i++){
		for(int j = 0; j <= 2 * n; j++){
			for(int k = 0; k < n; k++){
				for(int kk = 0; kk < cnt[id][i][j][k]; kk++){
					//cout << i << " " << j << " " << k << " " << kk << " " << save[i][j][k][kk].fi << " " << save[i][j][k][kk].se << "\n";	
				}
			}	
		}
	}
}
 
bool vis[N][N];
int val[N][N];
 
void ff(int i, int j, int n){
	//cout << i << " " << j << "\n";
	if(i < 0 || j < 0 || i >= (2 * n + 1) || j >= (2 * n + 1) || !val[i][j]) return;
	val[i][j] = 0;
	ff(i + 1, j, n);
	ff(i - 1, j, n);
	ff(i, j - 1, n);
	ff(i, j + 1, n);
}
 
string process(vector<vector<string>> a, int i, int j, int k, int n){
	prep(n);
	//cout << "OK\n";
	for(int ii = 0; ii <= 2 * n; ii++){
		for(int jj = 0; jj <= 2 * n; jj++) vis[ii][jj] = 0;
	}
	for(int ii = 0; ii <= 2; ii++){
		for(int jj = 0; jj <= 2; jj++){
			for(int kk = 0; kk < cnt[n][i + ii][j + jj][k]; kk++){
				int x = save[n][i + ii][j + jj][k][kk].fi, y = save[n][i + ii][j + jj][k][kk].se;
				val[x][y] = a[ii][jj][kk] - '0';
				vis[x][y] = 1;
				//cout << i << " " << j << " " << k << " " << x << " " << y << " " << val[x][y] << "\n";
			}
		}
	}
	if(k == n - 1){
		//exit(0);
		int ans = 0;
		/*
		for(int i = 0; i < (2 * n) + 1; i++){
			for(int j = 0; j < (2 * n) + 1; j++) cout << val[i][j] << " ";
			cout << "\n";
		}*/
		for(int i = 0; i < (2 * n + 1); i++){
			for(int j = 0; j < (2 * n + 1); j++){
				assert(vis[i][j]);
			//	cout << "OK " << i << " " << j << " " << val[i][j] << "\n";
				if(!val[i][j]) continue;
				ans++;
				ff(i, j, n);
			}
		}
		//cout << ans << "\n";
		string temp;
		for(int kk = 0; kk < 100; kk++) temp += '0';
		for(int kk = 0; kk < 20; kk++) if(ans & (1LL << kk)) temp[kk] = '1';
		return temp;
	}
	else{
		string temp;
		for(int kk = 0; kk < 100; kk++) temp += '0';
		for(int kk = 0; kk < cnt[n][i][j][k + 1]; kk++){
			int x = save[n][i][j][k + 1][kk].fi, y = save[n][i][j][k + 1][kk].se;
			assert(vis[x][y]);
			temp[kk] = char(48 + val[x][y]);
		}
		return temp;
	}
}

Compilation message

mars.cpp:16:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   16 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11544 KB Output is correct
2 Correct 14 ms 11384 KB Output is correct
3 Correct 13 ms 11428 KB Output is correct
4 Correct 13 ms 11204 KB Output is correct
5 Correct 14 ms 11264 KB Output is correct
6 Correct 13 ms 11464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11544 KB Output is correct
2 Correct 14 ms 11384 KB Output is correct
3 Correct 13 ms 11428 KB Output is correct
4 Correct 13 ms 11204 KB Output is correct
5 Correct 14 ms 11264 KB Output is correct
6 Correct 13 ms 11464 KB Output is correct
7 Correct 22 ms 16388 KB Output is correct
8 Correct 30 ms 13732 KB Output is correct
9 Correct 26 ms 13740 KB Output is correct
10 Correct 27 ms 13548 KB Output is correct
11 Correct 26 ms 13584 KB Output is correct
12 Correct 25 ms 13744 KB Output is correct
13 Correct 30 ms 13660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11544 KB Output is correct
2 Correct 14 ms 11384 KB Output is correct
3 Correct 13 ms 11428 KB Output is correct
4 Correct 13 ms 11204 KB Output is correct
5 Correct 14 ms 11264 KB Output is correct
6 Correct 13 ms 11464 KB Output is correct
7 Correct 22 ms 16388 KB Output is correct
8 Correct 30 ms 13732 KB Output is correct
9 Correct 26 ms 13740 KB Output is correct
10 Correct 27 ms 13548 KB Output is correct
11 Correct 26 ms 13584 KB Output is correct
12 Correct 25 ms 13744 KB Output is correct
13 Correct 30 ms 13660 KB Output is correct
14 Correct 61 ms 24340 KB Output is correct
15 Correct 102 ms 18992 KB Output is correct
16 Correct 92 ms 18972 KB Output is correct
17 Correct 92 ms 18988 KB Output is correct
18 Correct 94 ms 18976 KB Output is correct
19 Correct 91 ms 19000 KB Output is correct
20 Correct 88 ms 18960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11544 KB Output is correct
2 Correct 14 ms 11384 KB Output is correct
3 Correct 13 ms 11428 KB Output is correct
4 Correct 13 ms 11204 KB Output is correct
5 Correct 14 ms 11264 KB Output is correct
6 Correct 13 ms 11464 KB Output is correct
7 Correct 22 ms 16388 KB Output is correct
8 Correct 30 ms 13732 KB Output is correct
9 Correct 26 ms 13740 KB Output is correct
10 Correct 27 ms 13548 KB Output is correct
11 Correct 26 ms 13584 KB Output is correct
12 Correct 25 ms 13744 KB Output is correct
13 Correct 30 ms 13660 KB Output is correct
14 Correct 61 ms 24340 KB Output is correct
15 Correct 102 ms 18992 KB Output is correct
16 Correct 92 ms 18972 KB Output is correct
17 Correct 92 ms 18988 KB Output is correct
18 Correct 94 ms 18976 KB Output is correct
19 Correct 91 ms 19000 KB Output is correct
20 Correct 88 ms 18960 KB Output is correct
21 Correct 177 ms 21952 KB Output is correct
22 Correct 336 ms 25856 KB Output is correct
23 Correct 333 ms 25812 KB Output is correct
24 Correct 324 ms 25960 KB Output is correct
25 Correct 322 ms 25844 KB Output is correct
26 Correct 328 ms 25812 KB Output is correct
27 Correct 345 ms 25960 KB Output is correct
28 Correct 326 ms 25836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11544 KB Output is correct
2 Correct 14 ms 11384 KB Output is correct
3 Correct 13 ms 11428 KB Output is correct
4 Correct 13 ms 11204 KB Output is correct
5 Correct 14 ms 11264 KB Output is correct
6 Correct 13 ms 11464 KB Output is correct
7 Correct 22 ms 16388 KB Output is correct
8 Correct 30 ms 13732 KB Output is correct
9 Correct 26 ms 13740 KB Output is correct
10 Correct 27 ms 13548 KB Output is correct
11 Correct 26 ms 13584 KB Output is correct
12 Correct 25 ms 13744 KB Output is correct
13 Correct 30 ms 13660 KB Output is correct
14 Correct 61 ms 24340 KB Output is correct
15 Correct 102 ms 18992 KB Output is correct
16 Correct 92 ms 18972 KB Output is correct
17 Correct 92 ms 18988 KB Output is correct
18 Correct 94 ms 18976 KB Output is correct
19 Correct 91 ms 19000 KB Output is correct
20 Correct 88 ms 18960 KB Output is correct
21 Correct 177 ms 21952 KB Output is correct
22 Correct 336 ms 25856 KB Output is correct
23 Correct 333 ms 25812 KB Output is correct
24 Correct 324 ms 25960 KB Output is correct
25 Correct 322 ms 25844 KB Output is correct
26 Correct 328 ms 25812 KB Output is correct
27 Correct 345 ms 25960 KB Output is correct
28 Correct 326 ms 25836 KB Output is correct
29 Correct 601 ms 30480 KB Output is correct
30 Correct 1055 ms 35872 KB Output is correct
31 Correct 1046 ms 35988 KB Output is correct
32 Correct 1048 ms 35792 KB Output is correct
33 Correct 1033 ms 35964 KB Output is correct
34 Correct 1030 ms 35848 KB Output is correct
35 Correct 1041 ms 35828 KB Output is correct
36 Correct 1056 ms 36016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11544 KB Output is correct
2 Correct 14 ms 11384 KB Output is correct
3 Correct 13 ms 11428 KB Output is correct
4 Correct 13 ms 11204 KB Output is correct
5 Correct 14 ms 11264 KB Output is correct
6 Correct 13 ms 11464 KB Output is correct
7 Correct 22 ms 16388 KB Output is correct
8 Correct 30 ms 13732 KB Output is correct
9 Correct 26 ms 13740 KB Output is correct
10 Correct 27 ms 13548 KB Output is correct
11 Correct 26 ms 13584 KB Output is correct
12 Correct 25 ms 13744 KB Output is correct
13 Correct 30 ms 13660 KB Output is correct
14 Correct 61 ms 24340 KB Output is correct
15 Correct 102 ms 18992 KB Output is correct
16 Correct 92 ms 18972 KB Output is correct
17 Correct 92 ms 18988 KB Output is correct
18 Correct 94 ms 18976 KB Output is correct
19 Correct 91 ms 19000 KB Output is correct
20 Correct 88 ms 18960 KB Output is correct
21 Correct 177 ms 21952 KB Output is correct
22 Correct 336 ms 25856 KB Output is correct
23 Correct 333 ms 25812 KB Output is correct
24 Correct 324 ms 25960 KB Output is correct
25 Correct 322 ms 25844 KB Output is correct
26 Correct 328 ms 25812 KB Output is correct
27 Correct 345 ms 25960 KB Output is correct
28 Correct 326 ms 25836 KB Output is correct
29 Correct 601 ms 30480 KB Output is correct
30 Correct 1055 ms 35872 KB Output is correct
31 Correct 1046 ms 35988 KB Output is correct
32 Correct 1048 ms 35792 KB Output is correct
33 Correct 1033 ms 35964 KB Output is correct
34 Correct 1030 ms 35848 KB Output is correct
35 Correct 1041 ms 35828 KB Output is correct
36 Correct 1056 ms 36016 KB Output is correct
37 Incorrect 237 ms 5216 KB Incorrect
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11544 KB Output is correct
2 Correct 14 ms 11384 KB Output is correct
3 Correct 13 ms 11428 KB Output is correct
4 Correct 13 ms 11204 KB Output is correct
5 Correct 14 ms 11264 KB Output is correct
6 Correct 13 ms 11464 KB Output is correct
7 Correct 22 ms 16388 KB Output is correct
8 Correct 30 ms 13732 KB Output is correct
9 Correct 26 ms 13740 KB Output is correct
10 Correct 27 ms 13548 KB Output is correct
11 Correct 26 ms 13584 KB Output is correct
12 Correct 25 ms 13744 KB Output is correct
13 Correct 30 ms 13660 KB Output is correct
14 Correct 61 ms 24340 KB Output is correct
15 Correct 102 ms 18992 KB Output is correct
16 Correct 92 ms 18972 KB Output is correct
17 Correct 92 ms 18988 KB Output is correct
18 Correct 94 ms 18976 KB Output is correct
19 Correct 91 ms 19000 KB Output is correct
20 Correct 88 ms 18960 KB Output is correct
21 Correct 177 ms 21952 KB Output is correct
22 Correct 336 ms 25856 KB Output is correct
23 Correct 333 ms 25812 KB Output is correct
24 Correct 324 ms 25960 KB Output is correct
25 Correct 322 ms 25844 KB Output is correct
26 Correct 328 ms 25812 KB Output is correct
27 Correct 345 ms 25960 KB Output is correct
28 Correct 326 ms 25836 KB Output is correct
29 Correct 601 ms 30480 KB Output is correct
30 Correct 1055 ms 35872 KB Output is correct
31 Correct 1046 ms 35988 KB Output is correct
32 Correct 1048 ms 35792 KB Output is correct
33 Correct 1033 ms 35964 KB Output is correct
34 Correct 1030 ms 35848 KB Output is correct
35 Correct 1041 ms 35828 KB Output is correct
36 Correct 1056 ms 36016 KB Output is correct
37 Incorrect 237 ms 5216 KB Incorrect
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11544 KB Output is correct
2 Correct 14 ms 11384 KB Output is correct
3 Correct 13 ms 11428 KB Output is correct
4 Correct 13 ms 11204 KB Output is correct
5 Correct 14 ms 11264 KB Output is correct
6 Correct 13 ms 11464 KB Output is correct
7 Correct 22 ms 16388 KB Output is correct
8 Correct 30 ms 13732 KB Output is correct
9 Correct 26 ms 13740 KB Output is correct
10 Correct 27 ms 13548 KB Output is correct
11 Correct 26 ms 13584 KB Output is correct
12 Correct 25 ms 13744 KB Output is correct
13 Correct 30 ms 13660 KB Output is correct
14 Correct 61 ms 24340 KB Output is correct
15 Correct 102 ms 18992 KB Output is correct
16 Correct 92 ms 18972 KB Output is correct
17 Correct 92 ms 18988 KB Output is correct
18 Correct 94 ms 18976 KB Output is correct
19 Correct 91 ms 19000 KB Output is correct
20 Correct 88 ms 18960 KB Output is correct
21 Correct 177 ms 21952 KB Output is correct
22 Correct 336 ms 25856 KB Output is correct
23 Correct 333 ms 25812 KB Output is correct
24 Correct 324 ms 25960 KB Output is correct
25 Correct 322 ms 25844 KB Output is correct
26 Correct 328 ms 25812 KB Output is correct
27 Correct 345 ms 25960 KB Output is correct
28 Correct 326 ms 25836 KB Output is correct
29 Correct 601 ms 30480 KB Output is correct
30 Correct 1055 ms 35872 KB Output is correct
31 Correct 1046 ms 35988 KB Output is correct
32 Correct 1048 ms 35792 KB Output is correct
33 Correct 1033 ms 35964 KB Output is correct
34 Correct 1030 ms 35848 KB Output is correct
35 Correct 1041 ms 35828 KB Output is correct
36 Correct 1056 ms 36016 KB Output is correct
37 Incorrect 237 ms 5216 KB Incorrect
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11544 KB Output is correct
2 Correct 14 ms 11384 KB Output is correct
3 Correct 13 ms 11428 KB Output is correct
4 Correct 13 ms 11204 KB Output is correct
5 Correct 14 ms 11264 KB Output is correct
6 Correct 13 ms 11464 KB Output is correct
7 Correct 22 ms 16388 KB Output is correct
8 Correct 30 ms 13732 KB Output is correct
9 Correct 26 ms 13740 KB Output is correct
10 Correct 27 ms 13548 KB Output is correct
11 Correct 26 ms 13584 KB Output is correct
12 Correct 25 ms 13744 KB Output is correct
13 Correct 30 ms 13660 KB Output is correct
14 Correct 61 ms 24340 KB Output is correct
15 Correct 102 ms 18992 KB Output is correct
16 Correct 92 ms 18972 KB Output is correct
17 Correct 92 ms 18988 KB Output is correct
18 Correct 94 ms 18976 KB Output is correct
19 Correct 91 ms 19000 KB Output is correct
20 Correct 88 ms 18960 KB Output is correct
21 Correct 177 ms 21952 KB Output is correct
22 Correct 336 ms 25856 KB Output is correct
23 Correct 333 ms 25812 KB Output is correct
24 Correct 324 ms 25960 KB Output is correct
25 Correct 322 ms 25844 KB Output is correct
26 Correct 328 ms 25812 KB Output is correct
27 Correct 345 ms 25960 KB Output is correct
28 Correct 326 ms 25836 KB Output is correct
29 Correct 601 ms 30480 KB Output is correct
30 Correct 1055 ms 35872 KB Output is correct
31 Correct 1046 ms 35988 KB Output is correct
32 Correct 1048 ms 35792 KB Output is correct
33 Correct 1033 ms 35964 KB Output is correct
34 Correct 1030 ms 35848 KB Output is correct
35 Correct 1041 ms 35828 KB Output is correct
36 Correct 1056 ms 36016 KB Output is correct
37 Incorrect 237 ms 5216 KB Incorrect
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11544 KB Output is correct
2 Correct 14 ms 11384 KB Output is correct
3 Correct 13 ms 11428 KB Output is correct
4 Correct 13 ms 11204 KB Output is correct
5 Correct 14 ms 11264 KB Output is correct
6 Correct 13 ms 11464 KB Output is correct
7 Correct 22 ms 16388 KB Output is correct
8 Correct 30 ms 13732 KB Output is correct
9 Correct 26 ms 13740 KB Output is correct
10 Correct 27 ms 13548 KB Output is correct
11 Correct 26 ms 13584 KB Output is correct
12 Correct 25 ms 13744 KB Output is correct
13 Correct 30 ms 13660 KB Output is correct
14 Correct 61 ms 24340 KB Output is correct
15 Correct 102 ms 18992 KB Output is correct
16 Correct 92 ms 18972 KB Output is correct
17 Correct 92 ms 18988 KB Output is correct
18 Correct 94 ms 18976 KB Output is correct
19 Correct 91 ms 19000 KB Output is correct
20 Correct 88 ms 18960 KB Output is correct
21 Correct 177 ms 21952 KB Output is correct
22 Correct 336 ms 25856 KB Output is correct
23 Correct 333 ms 25812 KB Output is correct
24 Correct 324 ms 25960 KB Output is correct
25 Correct 322 ms 25844 KB Output is correct
26 Correct 328 ms 25812 KB Output is correct
27 Correct 345 ms 25960 KB Output is correct
28 Correct 326 ms 25836 KB Output is correct
29 Correct 601 ms 30480 KB Output is correct
30 Correct 1055 ms 35872 KB Output is correct
31 Correct 1046 ms 35988 KB Output is correct
32 Correct 1048 ms 35792 KB Output is correct
33 Correct 1033 ms 35964 KB Output is correct
34 Correct 1030 ms 35848 KB Output is correct
35 Correct 1041 ms 35828 KB Output is correct
36 Correct 1056 ms 36016 KB Output is correct
37 Incorrect 237 ms 5216 KB Incorrect
38 Halted 0 ms 0 KB -