This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "mars.h"
using namespace std;
#define SIZE 100
string collect(const vector<vector<string>> &a, int k) {
string ans = a[0][0].substr(0, 2 * k + 1) + a[0][1][2 * k] + a[0][2][2 * k]
+ a[1][0].substr(0, 2 * k + 1) + a[1][1][2 * k] + a[1][2][2 * k]
+ a[2][0].substr(0, 2 * k + 1) + a[2][1][2 * k] + a[2][2][2 * k]
+ a[2][0].substr(2 * k + 1, 2 * k + 1) + a[2][1][4 * k + 1] + a[2][2][4 * k + 1]
+ a[2][0].substr(4 * k + 2, 2 * k + 1) + a[2][1][6 * k + 2] + a[2][2][6 * k + 2];
return ans + string(SIZE - ans.size(), '0');
}
string cc(const vector<vector<string>> &a, int n) {
string grid = collect(a, n - 1);
int m = 2 * n + 1;
auto get = [&](int i, int j) { return grid[m * i + j] == '1'; };
vector<vector<bool>> vis(m, vector<bool>(m));
int cnt = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
if (vis[i][j] || !get(i, j)) continue;
cnt++;
queue<pair<int, int>> q;
q.emplace(i, j);
while (!q.empty()) {
auto [x, y] = q.front(); q.pop();
if (vis[x][y] || !get(x, y)) continue;
vis[x][y] = true;
if (x > 0)
q.emplace(x - 1, y);
if (x < m - 1)
q.emplace(x + 1, y);
if (y > 0)
q.emplace(x, y - 1);
if (y < m - 1)
q.emplace(x, y + 1);
}
}
}
string ans(SIZE, '0');
for (int i = 0; i < SIZE; i++) {
if (cnt & 1)
ans[i] = '1';
cnt >>= 1;
}
return ans;
}
string process(vector<vector<string>> a, int i, int j, int k, int n) {
if (k == n - 1)
return cc(a, n);
if (k <= 3)
return collect(a, k);
assert(false);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |