# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
731108 |
2023-04-27T03:02:29 Z |
hoainiem |
Mars (APIO22_mars) |
C++17 |
|
288 ms |
25644 KB |
#include "mars.h"
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
int get(int i, int j, int n){
i /= 2;
j /= 2;
n = n / 2 + (n & 1);
return i * n + j;
}
string operator|(string x, string y){
for (int i = 0; i < 100; i++)
if (y[i] == '1')
x[i] = y[i];
return x;
}
std::string process(std::vector <std::vector<std::string>> a, int x, int y, int k, int n){
if (!k)
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
if (a[i][j][0] == '1'){
a[i][j][0] = '0';
a[i][j][get(x + i, y + j, n * 2 + 1)] = '1';
}
a[0][0] = a[0][0] | a[2][0] | a[0][2] | a[2][2];
if (k < n - 1)
return a[0][0];
n = n * 2 + 1;
a[0][1] = a[0][1] | a[2][1];
a[1][0] = a[1][0] | a[1][2];
bitset<1608>land[1608];
int h1[4]{1, -1, 0, 0};
int h2[4]{0, 0, 1, -1};
bool vis[1608][1608];
for (int i = 0; i < n; i++)
land[i].reset();
for (x = 0; x < 2; x++)
for (int y = 0; y < 2; y++)
for (int i = x; i < n; i += 2)
for (int j = y; j < n; j += 2)
if (a[x][y][get(i, j, n)] == '1')
land[i].set(j);
memset(vis, false, sizeof(vis));
queue<pii>s;
int ans = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (!vis[i][j] && land[i].test(j)){
ans++;
s.push({i, j});
vis[i][j] = true;
while (!s.empty()){
pii u = s.front();
s.pop();
for (int c = 0; c < 4; c++){
pii v = {u.fi + h1[c], u.se + h2[c]};
if (v.fi < 0 || v.fi >= n || v.se < 0 || v.se >= n || !land[v.fi].test(v.se) || vis[v.fi][v.se])
continue;
s.push(v);
vis[v.fi][v.se] = true;
}
}
}
string res;
res.resize(100, '0');
for (int i = 0; i < 15; i++)
if ((ans >> i) & 1)
res[i] = '1';
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
25036 KB |
Output is correct |
2 |
Correct |
20 ms |
25020 KB |
Output is correct |
3 |
Correct |
22 ms |
25108 KB |
Output is correct |
4 |
Correct |
21 ms |
24848 KB |
Output is correct |
5 |
Correct |
22 ms |
24896 KB |
Output is correct |
6 |
Correct |
22 ms |
24940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
25036 KB |
Output is correct |
2 |
Correct |
20 ms |
25020 KB |
Output is correct |
3 |
Correct |
22 ms |
25108 KB |
Output is correct |
4 |
Correct |
21 ms |
24848 KB |
Output is correct |
5 |
Correct |
22 ms |
24896 KB |
Output is correct |
6 |
Correct |
22 ms |
24940 KB |
Output is correct |
7 |
Correct |
40 ms |
24920 KB |
Output is correct |
8 |
Correct |
45 ms |
25004 KB |
Output is correct |
9 |
Correct |
44 ms |
25020 KB |
Output is correct |
10 |
Correct |
48 ms |
24816 KB |
Output is correct |
11 |
Correct |
46 ms |
25044 KB |
Output is correct |
12 |
Correct |
41 ms |
25104 KB |
Output is correct |
13 |
Correct |
40 ms |
24912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
25036 KB |
Output is correct |
2 |
Correct |
20 ms |
25020 KB |
Output is correct |
3 |
Correct |
22 ms |
25108 KB |
Output is correct |
4 |
Correct |
21 ms |
24848 KB |
Output is correct |
5 |
Correct |
22 ms |
24896 KB |
Output is correct |
6 |
Correct |
22 ms |
24940 KB |
Output is correct |
7 |
Correct |
40 ms |
24920 KB |
Output is correct |
8 |
Correct |
45 ms |
25004 KB |
Output is correct |
9 |
Correct |
44 ms |
25020 KB |
Output is correct |
10 |
Correct |
48 ms |
24816 KB |
Output is correct |
11 |
Correct |
46 ms |
25044 KB |
Output is correct |
12 |
Correct |
41 ms |
25104 KB |
Output is correct |
13 |
Correct |
40 ms |
24912 KB |
Output is correct |
14 |
Correct |
74 ms |
25232 KB |
Output is correct |
15 |
Correct |
100 ms |
25292 KB |
Output is correct |
16 |
Correct |
97 ms |
25324 KB |
Output is correct |
17 |
Correct |
95 ms |
25288 KB |
Output is correct |
18 |
Correct |
98 ms |
25408 KB |
Output is correct |
19 |
Correct |
95 ms |
25312 KB |
Output is correct |
20 |
Correct |
93 ms |
25440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
25036 KB |
Output is correct |
2 |
Correct |
20 ms |
25020 KB |
Output is correct |
3 |
Correct |
22 ms |
25108 KB |
Output is correct |
4 |
Correct |
21 ms |
24848 KB |
Output is correct |
5 |
Correct |
22 ms |
24896 KB |
Output is correct |
6 |
Correct |
22 ms |
24940 KB |
Output is correct |
7 |
Correct |
40 ms |
24920 KB |
Output is correct |
8 |
Correct |
45 ms |
25004 KB |
Output is correct |
9 |
Correct |
44 ms |
25020 KB |
Output is correct |
10 |
Correct |
48 ms |
24816 KB |
Output is correct |
11 |
Correct |
46 ms |
25044 KB |
Output is correct |
12 |
Correct |
41 ms |
25104 KB |
Output is correct |
13 |
Correct |
40 ms |
24912 KB |
Output is correct |
14 |
Correct |
74 ms |
25232 KB |
Output is correct |
15 |
Correct |
100 ms |
25292 KB |
Output is correct |
16 |
Correct |
97 ms |
25324 KB |
Output is correct |
17 |
Correct |
95 ms |
25288 KB |
Output is correct |
18 |
Correct |
98 ms |
25408 KB |
Output is correct |
19 |
Correct |
95 ms |
25312 KB |
Output is correct |
20 |
Correct |
93 ms |
25440 KB |
Output is correct |
21 |
Correct |
148 ms |
25360 KB |
Output is correct |
22 |
Correct |
203 ms |
25472 KB |
Output is correct |
23 |
Correct |
200 ms |
25568 KB |
Output is correct |
24 |
Correct |
199 ms |
25524 KB |
Output is correct |
25 |
Correct |
214 ms |
25592 KB |
Output is correct |
26 |
Correct |
214 ms |
25496 KB |
Output is correct |
27 |
Correct |
211 ms |
25496 KB |
Output is correct |
28 |
Correct |
209 ms |
25528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
25036 KB |
Output is correct |
2 |
Correct |
20 ms |
25020 KB |
Output is correct |
3 |
Correct |
22 ms |
25108 KB |
Output is correct |
4 |
Correct |
21 ms |
24848 KB |
Output is correct |
5 |
Correct |
22 ms |
24896 KB |
Output is correct |
6 |
Correct |
22 ms |
24940 KB |
Output is correct |
7 |
Correct |
40 ms |
24920 KB |
Output is correct |
8 |
Correct |
45 ms |
25004 KB |
Output is correct |
9 |
Correct |
44 ms |
25020 KB |
Output is correct |
10 |
Correct |
48 ms |
24816 KB |
Output is correct |
11 |
Correct |
46 ms |
25044 KB |
Output is correct |
12 |
Correct |
41 ms |
25104 KB |
Output is correct |
13 |
Correct |
40 ms |
24912 KB |
Output is correct |
14 |
Correct |
74 ms |
25232 KB |
Output is correct |
15 |
Correct |
100 ms |
25292 KB |
Output is correct |
16 |
Correct |
97 ms |
25324 KB |
Output is correct |
17 |
Correct |
95 ms |
25288 KB |
Output is correct |
18 |
Correct |
98 ms |
25408 KB |
Output is correct |
19 |
Correct |
95 ms |
25312 KB |
Output is correct |
20 |
Correct |
93 ms |
25440 KB |
Output is correct |
21 |
Correct |
148 ms |
25360 KB |
Output is correct |
22 |
Correct |
203 ms |
25472 KB |
Output is correct |
23 |
Correct |
200 ms |
25568 KB |
Output is correct |
24 |
Correct |
199 ms |
25524 KB |
Output is correct |
25 |
Correct |
214 ms |
25592 KB |
Output is correct |
26 |
Correct |
214 ms |
25496 KB |
Output is correct |
27 |
Correct |
211 ms |
25496 KB |
Output is correct |
28 |
Correct |
209 ms |
25528 KB |
Output is correct |
29 |
Correct |
288 ms |
25644 KB |
Output is correct |
30 |
Runtime error |
14 ms |
6480 KB |
Execution killed with signal 6 |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
25036 KB |
Output is correct |
2 |
Correct |
20 ms |
25020 KB |
Output is correct |
3 |
Correct |
22 ms |
25108 KB |
Output is correct |
4 |
Correct |
21 ms |
24848 KB |
Output is correct |
5 |
Correct |
22 ms |
24896 KB |
Output is correct |
6 |
Correct |
22 ms |
24940 KB |
Output is correct |
7 |
Correct |
40 ms |
24920 KB |
Output is correct |
8 |
Correct |
45 ms |
25004 KB |
Output is correct |
9 |
Correct |
44 ms |
25020 KB |
Output is correct |
10 |
Correct |
48 ms |
24816 KB |
Output is correct |
11 |
Correct |
46 ms |
25044 KB |
Output is correct |
12 |
Correct |
41 ms |
25104 KB |
Output is correct |
13 |
Correct |
40 ms |
24912 KB |
Output is correct |
14 |
Correct |
74 ms |
25232 KB |
Output is correct |
15 |
Correct |
100 ms |
25292 KB |
Output is correct |
16 |
Correct |
97 ms |
25324 KB |
Output is correct |
17 |
Correct |
95 ms |
25288 KB |
Output is correct |
18 |
Correct |
98 ms |
25408 KB |
Output is correct |
19 |
Correct |
95 ms |
25312 KB |
Output is correct |
20 |
Correct |
93 ms |
25440 KB |
Output is correct |
21 |
Correct |
148 ms |
25360 KB |
Output is correct |
22 |
Correct |
203 ms |
25472 KB |
Output is correct |
23 |
Correct |
200 ms |
25568 KB |
Output is correct |
24 |
Correct |
199 ms |
25524 KB |
Output is correct |
25 |
Correct |
214 ms |
25592 KB |
Output is correct |
26 |
Correct |
214 ms |
25496 KB |
Output is correct |
27 |
Correct |
211 ms |
25496 KB |
Output is correct |
28 |
Correct |
209 ms |
25528 KB |
Output is correct |
29 |
Correct |
288 ms |
25644 KB |
Output is correct |
30 |
Runtime error |
14 ms |
6480 KB |
Execution killed with signal 6 |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
25036 KB |
Output is correct |
2 |
Correct |
20 ms |
25020 KB |
Output is correct |
3 |
Correct |
22 ms |
25108 KB |
Output is correct |
4 |
Correct |
21 ms |
24848 KB |
Output is correct |
5 |
Correct |
22 ms |
24896 KB |
Output is correct |
6 |
Correct |
22 ms |
24940 KB |
Output is correct |
7 |
Correct |
40 ms |
24920 KB |
Output is correct |
8 |
Correct |
45 ms |
25004 KB |
Output is correct |
9 |
Correct |
44 ms |
25020 KB |
Output is correct |
10 |
Correct |
48 ms |
24816 KB |
Output is correct |
11 |
Correct |
46 ms |
25044 KB |
Output is correct |
12 |
Correct |
41 ms |
25104 KB |
Output is correct |
13 |
Correct |
40 ms |
24912 KB |
Output is correct |
14 |
Correct |
74 ms |
25232 KB |
Output is correct |
15 |
Correct |
100 ms |
25292 KB |
Output is correct |
16 |
Correct |
97 ms |
25324 KB |
Output is correct |
17 |
Correct |
95 ms |
25288 KB |
Output is correct |
18 |
Correct |
98 ms |
25408 KB |
Output is correct |
19 |
Correct |
95 ms |
25312 KB |
Output is correct |
20 |
Correct |
93 ms |
25440 KB |
Output is correct |
21 |
Correct |
148 ms |
25360 KB |
Output is correct |
22 |
Correct |
203 ms |
25472 KB |
Output is correct |
23 |
Correct |
200 ms |
25568 KB |
Output is correct |
24 |
Correct |
199 ms |
25524 KB |
Output is correct |
25 |
Correct |
214 ms |
25592 KB |
Output is correct |
26 |
Correct |
214 ms |
25496 KB |
Output is correct |
27 |
Correct |
211 ms |
25496 KB |
Output is correct |
28 |
Correct |
209 ms |
25528 KB |
Output is correct |
29 |
Correct |
288 ms |
25644 KB |
Output is correct |
30 |
Runtime error |
14 ms |
6480 KB |
Execution killed with signal 6 |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
25036 KB |
Output is correct |
2 |
Correct |
20 ms |
25020 KB |
Output is correct |
3 |
Correct |
22 ms |
25108 KB |
Output is correct |
4 |
Correct |
21 ms |
24848 KB |
Output is correct |
5 |
Correct |
22 ms |
24896 KB |
Output is correct |
6 |
Correct |
22 ms |
24940 KB |
Output is correct |
7 |
Correct |
40 ms |
24920 KB |
Output is correct |
8 |
Correct |
45 ms |
25004 KB |
Output is correct |
9 |
Correct |
44 ms |
25020 KB |
Output is correct |
10 |
Correct |
48 ms |
24816 KB |
Output is correct |
11 |
Correct |
46 ms |
25044 KB |
Output is correct |
12 |
Correct |
41 ms |
25104 KB |
Output is correct |
13 |
Correct |
40 ms |
24912 KB |
Output is correct |
14 |
Correct |
74 ms |
25232 KB |
Output is correct |
15 |
Correct |
100 ms |
25292 KB |
Output is correct |
16 |
Correct |
97 ms |
25324 KB |
Output is correct |
17 |
Correct |
95 ms |
25288 KB |
Output is correct |
18 |
Correct |
98 ms |
25408 KB |
Output is correct |
19 |
Correct |
95 ms |
25312 KB |
Output is correct |
20 |
Correct |
93 ms |
25440 KB |
Output is correct |
21 |
Correct |
148 ms |
25360 KB |
Output is correct |
22 |
Correct |
203 ms |
25472 KB |
Output is correct |
23 |
Correct |
200 ms |
25568 KB |
Output is correct |
24 |
Correct |
199 ms |
25524 KB |
Output is correct |
25 |
Correct |
214 ms |
25592 KB |
Output is correct |
26 |
Correct |
214 ms |
25496 KB |
Output is correct |
27 |
Correct |
211 ms |
25496 KB |
Output is correct |
28 |
Correct |
209 ms |
25528 KB |
Output is correct |
29 |
Correct |
288 ms |
25644 KB |
Output is correct |
30 |
Runtime error |
14 ms |
6480 KB |
Execution killed with signal 6 |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
25036 KB |
Output is correct |
2 |
Correct |
20 ms |
25020 KB |
Output is correct |
3 |
Correct |
22 ms |
25108 KB |
Output is correct |
4 |
Correct |
21 ms |
24848 KB |
Output is correct |
5 |
Correct |
22 ms |
24896 KB |
Output is correct |
6 |
Correct |
22 ms |
24940 KB |
Output is correct |
7 |
Correct |
40 ms |
24920 KB |
Output is correct |
8 |
Correct |
45 ms |
25004 KB |
Output is correct |
9 |
Correct |
44 ms |
25020 KB |
Output is correct |
10 |
Correct |
48 ms |
24816 KB |
Output is correct |
11 |
Correct |
46 ms |
25044 KB |
Output is correct |
12 |
Correct |
41 ms |
25104 KB |
Output is correct |
13 |
Correct |
40 ms |
24912 KB |
Output is correct |
14 |
Correct |
74 ms |
25232 KB |
Output is correct |
15 |
Correct |
100 ms |
25292 KB |
Output is correct |
16 |
Correct |
97 ms |
25324 KB |
Output is correct |
17 |
Correct |
95 ms |
25288 KB |
Output is correct |
18 |
Correct |
98 ms |
25408 KB |
Output is correct |
19 |
Correct |
95 ms |
25312 KB |
Output is correct |
20 |
Correct |
93 ms |
25440 KB |
Output is correct |
21 |
Correct |
148 ms |
25360 KB |
Output is correct |
22 |
Correct |
203 ms |
25472 KB |
Output is correct |
23 |
Correct |
200 ms |
25568 KB |
Output is correct |
24 |
Correct |
199 ms |
25524 KB |
Output is correct |
25 |
Correct |
214 ms |
25592 KB |
Output is correct |
26 |
Correct |
214 ms |
25496 KB |
Output is correct |
27 |
Correct |
211 ms |
25496 KB |
Output is correct |
28 |
Correct |
209 ms |
25528 KB |
Output is correct |
29 |
Correct |
288 ms |
25644 KB |
Output is correct |
30 |
Runtime error |
14 ms |
6480 KB |
Execution killed with signal 6 |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
25036 KB |
Output is correct |
2 |
Correct |
20 ms |
25020 KB |
Output is correct |
3 |
Correct |
22 ms |
25108 KB |
Output is correct |
4 |
Correct |
21 ms |
24848 KB |
Output is correct |
5 |
Correct |
22 ms |
24896 KB |
Output is correct |
6 |
Correct |
22 ms |
24940 KB |
Output is correct |
7 |
Correct |
40 ms |
24920 KB |
Output is correct |
8 |
Correct |
45 ms |
25004 KB |
Output is correct |
9 |
Correct |
44 ms |
25020 KB |
Output is correct |
10 |
Correct |
48 ms |
24816 KB |
Output is correct |
11 |
Correct |
46 ms |
25044 KB |
Output is correct |
12 |
Correct |
41 ms |
25104 KB |
Output is correct |
13 |
Correct |
40 ms |
24912 KB |
Output is correct |
14 |
Correct |
74 ms |
25232 KB |
Output is correct |
15 |
Correct |
100 ms |
25292 KB |
Output is correct |
16 |
Correct |
97 ms |
25324 KB |
Output is correct |
17 |
Correct |
95 ms |
25288 KB |
Output is correct |
18 |
Correct |
98 ms |
25408 KB |
Output is correct |
19 |
Correct |
95 ms |
25312 KB |
Output is correct |
20 |
Correct |
93 ms |
25440 KB |
Output is correct |
21 |
Correct |
148 ms |
25360 KB |
Output is correct |
22 |
Correct |
203 ms |
25472 KB |
Output is correct |
23 |
Correct |
200 ms |
25568 KB |
Output is correct |
24 |
Correct |
199 ms |
25524 KB |
Output is correct |
25 |
Correct |
214 ms |
25592 KB |
Output is correct |
26 |
Correct |
214 ms |
25496 KB |
Output is correct |
27 |
Correct |
211 ms |
25496 KB |
Output is correct |
28 |
Correct |
209 ms |
25528 KB |
Output is correct |
29 |
Correct |
288 ms |
25644 KB |
Output is correct |
30 |
Runtime error |
14 ms |
6480 KB |
Execution killed with signal 6 |
31 |
Halted |
0 ms |
0 KB |
- |