# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
982741 |
2024-05-14T16:58:38 Z |
vjudge1 |
Mars (APIO22_mars) |
C++17 |
|
13 ms |
4364 KB |
#include "mars.h"
#include <bits/stdc++.h>
#define all(x) begin((x)), end((x))
using ll = long long;
using namespace std;
ll countIslands(bitset<100> g, ll l) {
ll ans = 0;
vector<vector<bool>> vis(101, vector<bool>(101));
for (int r = 0; r < l; r++)
for (int c = 0; c < l; c++) {
if (vis[r][c] || !g[r * l + c]) continue;
ans++;
queue<pair<ll, ll>> q;
q.push({r, c});
while (q.size()) {
ll nr = q.front().first, nc = q.front().second;
q.pop();
if (vis[nr][nc] || !g[nr * l + nc]) continue;
vis[nr][nc] = true;
for (int i = -1; i <= 1; i++)
if (nr + i >= 0 && nr + i < l && !vis[nr + i][nc]
&& g[(nr + i) * l + nc])
q.push({nr + i, nc});
for (int i = -1; i <= 1; i++)
if (nc + i >= 0 && nc + i < l && !vis[nr][nc + i]
&& g[(nr)*l + (nc + i)])
q.push({nr, nc + i});
}
}
return ans;
}
string process(vector<vector<string>> a, int i, int j, int k, int n) {
ll l = 2 * n + 1;
bitset<100> x;
for (int r = 0; r < 3; r++)
for (int c = 0; c < 3; c++) {
reverse(all(a[r][c]));
bitset<100> q(a[r][c]);
ll idx = 1 + (i + r) * l + (j + c);
x[idx] = q[0];
q[0] = 0;
x |= q;
}
if (k == n - 1) {
x >>= 1;
ll ans = countIslands(x, l);
string res = bitset<100>(ans).to_string();
reverse(all(res));
return res;
}
string s = x.to_string();
reverse(all(s));
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4168 KB |
Output is correct |
2 |
Correct |
8 ms |
3848 KB |
Output is correct |
3 |
Correct |
8 ms |
4188 KB |
Output is correct |
4 |
Correct |
7 ms |
4128 KB |
Output is correct |
5 |
Correct |
8 ms |
3868 KB |
Output is correct |
6 |
Correct |
5 ms |
4248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4168 KB |
Output is correct |
2 |
Correct |
8 ms |
3848 KB |
Output is correct |
3 |
Correct |
8 ms |
4188 KB |
Output is correct |
4 |
Correct |
7 ms |
4128 KB |
Output is correct |
5 |
Correct |
8 ms |
3868 KB |
Output is correct |
6 |
Correct |
5 ms |
4248 KB |
Output is correct |
7 |
Correct |
8 ms |
4364 KB |
Output is correct |
8 |
Correct |
12 ms |
3728 KB |
Output is correct |
9 |
Correct |
13 ms |
3828 KB |
Output is correct |
10 |
Correct |
13 ms |
4104 KB |
Output is correct |
11 |
Correct |
10 ms |
4028 KB |
Output is correct |
12 |
Correct |
10 ms |
3848 KB |
Output is correct |
13 |
Correct |
12 ms |
3708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4168 KB |
Output is correct |
2 |
Correct |
8 ms |
3848 KB |
Output is correct |
3 |
Correct |
8 ms |
4188 KB |
Output is correct |
4 |
Correct |
7 ms |
4128 KB |
Output is correct |
5 |
Correct |
8 ms |
3868 KB |
Output is correct |
6 |
Correct |
5 ms |
4248 KB |
Output is correct |
7 |
Correct |
8 ms |
4364 KB |
Output is correct |
8 |
Correct |
12 ms |
3728 KB |
Output is correct |
9 |
Correct |
13 ms |
3828 KB |
Output is correct |
10 |
Correct |
13 ms |
4104 KB |
Output is correct |
11 |
Correct |
10 ms |
4028 KB |
Output is correct |
12 |
Correct |
10 ms |
3848 KB |
Output is correct |
13 |
Correct |
12 ms |
3708 KB |
Output is correct |
14 |
Incorrect |
2 ms |
456 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4168 KB |
Output is correct |
2 |
Correct |
8 ms |
3848 KB |
Output is correct |
3 |
Correct |
8 ms |
4188 KB |
Output is correct |
4 |
Correct |
7 ms |
4128 KB |
Output is correct |
5 |
Correct |
8 ms |
3868 KB |
Output is correct |
6 |
Correct |
5 ms |
4248 KB |
Output is correct |
7 |
Correct |
8 ms |
4364 KB |
Output is correct |
8 |
Correct |
12 ms |
3728 KB |
Output is correct |
9 |
Correct |
13 ms |
3828 KB |
Output is correct |
10 |
Correct |
13 ms |
4104 KB |
Output is correct |
11 |
Correct |
10 ms |
4028 KB |
Output is correct |
12 |
Correct |
10 ms |
3848 KB |
Output is correct |
13 |
Correct |
12 ms |
3708 KB |
Output is correct |
14 |
Incorrect |
2 ms |
456 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4168 KB |
Output is correct |
2 |
Correct |
8 ms |
3848 KB |
Output is correct |
3 |
Correct |
8 ms |
4188 KB |
Output is correct |
4 |
Correct |
7 ms |
4128 KB |
Output is correct |
5 |
Correct |
8 ms |
3868 KB |
Output is correct |
6 |
Correct |
5 ms |
4248 KB |
Output is correct |
7 |
Correct |
8 ms |
4364 KB |
Output is correct |
8 |
Correct |
12 ms |
3728 KB |
Output is correct |
9 |
Correct |
13 ms |
3828 KB |
Output is correct |
10 |
Correct |
13 ms |
4104 KB |
Output is correct |
11 |
Correct |
10 ms |
4028 KB |
Output is correct |
12 |
Correct |
10 ms |
3848 KB |
Output is correct |
13 |
Correct |
12 ms |
3708 KB |
Output is correct |
14 |
Incorrect |
2 ms |
456 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4168 KB |
Output is correct |
2 |
Correct |
8 ms |
3848 KB |
Output is correct |
3 |
Correct |
8 ms |
4188 KB |
Output is correct |
4 |
Correct |
7 ms |
4128 KB |
Output is correct |
5 |
Correct |
8 ms |
3868 KB |
Output is correct |
6 |
Correct |
5 ms |
4248 KB |
Output is correct |
7 |
Correct |
8 ms |
4364 KB |
Output is correct |
8 |
Correct |
12 ms |
3728 KB |
Output is correct |
9 |
Correct |
13 ms |
3828 KB |
Output is correct |
10 |
Correct |
13 ms |
4104 KB |
Output is correct |
11 |
Correct |
10 ms |
4028 KB |
Output is correct |
12 |
Correct |
10 ms |
3848 KB |
Output is correct |
13 |
Correct |
12 ms |
3708 KB |
Output is correct |
14 |
Incorrect |
2 ms |
456 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4168 KB |
Output is correct |
2 |
Correct |
8 ms |
3848 KB |
Output is correct |
3 |
Correct |
8 ms |
4188 KB |
Output is correct |
4 |
Correct |
7 ms |
4128 KB |
Output is correct |
5 |
Correct |
8 ms |
3868 KB |
Output is correct |
6 |
Correct |
5 ms |
4248 KB |
Output is correct |
7 |
Correct |
8 ms |
4364 KB |
Output is correct |
8 |
Correct |
12 ms |
3728 KB |
Output is correct |
9 |
Correct |
13 ms |
3828 KB |
Output is correct |
10 |
Correct |
13 ms |
4104 KB |
Output is correct |
11 |
Correct |
10 ms |
4028 KB |
Output is correct |
12 |
Correct |
10 ms |
3848 KB |
Output is correct |
13 |
Correct |
12 ms |
3708 KB |
Output is correct |
14 |
Incorrect |
2 ms |
456 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4168 KB |
Output is correct |
2 |
Correct |
8 ms |
3848 KB |
Output is correct |
3 |
Correct |
8 ms |
4188 KB |
Output is correct |
4 |
Correct |
7 ms |
4128 KB |
Output is correct |
5 |
Correct |
8 ms |
3868 KB |
Output is correct |
6 |
Correct |
5 ms |
4248 KB |
Output is correct |
7 |
Correct |
8 ms |
4364 KB |
Output is correct |
8 |
Correct |
12 ms |
3728 KB |
Output is correct |
9 |
Correct |
13 ms |
3828 KB |
Output is correct |
10 |
Correct |
13 ms |
4104 KB |
Output is correct |
11 |
Correct |
10 ms |
4028 KB |
Output is correct |
12 |
Correct |
10 ms |
3848 KB |
Output is correct |
13 |
Correct |
12 ms |
3708 KB |
Output is correct |
14 |
Incorrect |
2 ms |
456 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4168 KB |
Output is correct |
2 |
Correct |
8 ms |
3848 KB |
Output is correct |
3 |
Correct |
8 ms |
4188 KB |
Output is correct |
4 |
Correct |
7 ms |
4128 KB |
Output is correct |
5 |
Correct |
8 ms |
3868 KB |
Output is correct |
6 |
Correct |
5 ms |
4248 KB |
Output is correct |
7 |
Correct |
8 ms |
4364 KB |
Output is correct |
8 |
Correct |
12 ms |
3728 KB |
Output is correct |
9 |
Correct |
13 ms |
3828 KB |
Output is correct |
10 |
Correct |
13 ms |
4104 KB |
Output is correct |
11 |
Correct |
10 ms |
4028 KB |
Output is correct |
12 |
Correct |
10 ms |
3848 KB |
Output is correct |
13 |
Correct |
12 ms |
3708 KB |
Output is correct |
14 |
Incorrect |
2 ms |
456 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4168 KB |
Output is correct |
2 |
Correct |
8 ms |
3848 KB |
Output is correct |
3 |
Correct |
8 ms |
4188 KB |
Output is correct |
4 |
Correct |
7 ms |
4128 KB |
Output is correct |
5 |
Correct |
8 ms |
3868 KB |
Output is correct |
6 |
Correct |
5 ms |
4248 KB |
Output is correct |
7 |
Correct |
8 ms |
4364 KB |
Output is correct |
8 |
Correct |
12 ms |
3728 KB |
Output is correct |
9 |
Correct |
13 ms |
3828 KB |
Output is correct |
10 |
Correct |
13 ms |
4104 KB |
Output is correct |
11 |
Correct |
10 ms |
4028 KB |
Output is correct |
12 |
Correct |
10 ms |
3848 KB |
Output is correct |
13 |
Correct |
12 ms |
3708 KB |
Output is correct |
14 |
Incorrect |
2 ms |
456 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |