# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
594728 |
2022-07-12T22:00:02 Z |
lunchbox |
Mars (APIO22_mars) |
C++17 |
|
0 ms |
200 KB |
#include <bits/stdc++.h>
using namespace std;
struct dsu {
vector<int> ds;
dsu() {}
dsu(int n) {
ds.assign(n, -1);
}
const int& operator[](int i) {
return ds[i];
}
int find(int i) {
return ds[i] < 0 ? i : ds[i] = find(ds[i]);
}
int size(int i) {
return -ds[find(i)];
}
bool same(int i, int j) {
return find(i) == find(j);
}
bool join(int i, int j) {
i = find(i), j = find(j);
if (i == j)
return false;
if (ds[i] > ds[j])
swap(i, j);
ds[i] += ds[j], ds[j] = i;
return true;
}
};
string process(vector<vector<string>> ss, int i, int j, int k, int n) {
int n_ = (k + 1) * 2 + 1;
string s(100, '0');
for (int x1 = 0; x1 < 3; x1++)
for (int y1 = 0; y1 < 3; y1++)
for (int x2 = 0; x2 < n_ - 2; x2++)
for (int y2 = 0; y2 < n_ - 2; y2++)
s[(x1 + x2) * n_ + (y1 + y2)] = ss[x1][y1][x2 * (n_ - 2) + y2];
if (k < n - 1)
return s;
else {
dsu ds(n_ * n_);
int m = n_ * n_;
for (int x = 0; x < n_; x++)
for (int y = 0; y < n_; y++)
if (s[x * n_ + y] == '1') {
if (x > 0 && s[(x - 1) * n_ + y] == '1' && ds.join(x * n_ + y, (x - 1) * n_ + y))
m--;
if (y > 0 && s[x * n_ + (y - 1)] == '1' && ds.join(x * n_ + y, x * n_ + (y - 1)))
m--;
}
string t(100, '0');
for (int b = 0; b < 10; b++)
t[b] = '0' + (m >> b & 1);
return t;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |