# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
982731 |
2024-05-14T16:45:41 Z |
vjudge1 |
Mars (APIO22_mars) |
C++17 |
|
1 ms |
432 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;
}
string s = x.to_string();
reverse(all(s));
if (k == n - 1) {
x <<= 1;
ll ans = countIslands(x, l);
string res = bitset<100>(ans).to_string();
reverse(all(res));
return res;
}
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |