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>
using namespace std;
template<typename Fun>
struct y_combinator {
const Fun fun;
explicit y_combinator(const Fun&& fun) : fun(std::forward<const Fun>(fun)) {}
template<typename... Args>
auto operator()(Args&&... args) const {
return fun(std::ref(*this), std::forward<Args>(args)...);
}
};
string process(vector<vector<string>> a, int i, int j, int k, int n) {
if (k == n - 1) {
vector<string> g(n * 2 + 1, string(n * 2 + 1, '0'));
vector<vector<int>> used(n * 2 + 1, vector<int>(n * 2 + 1));
for (int x = 0; x < 3; ++x) {
for (int y = 0; y < 3; ++y) {
int p = 0;
for (int i = x; i < x + 3 + (k - 1) * 2; i += 2) {
for (int j = y; j < y + 3 + (k - 1) * 2; j += 2) {
g[i][j] = a[x][y][p];
p++;
}
}
}
}
int ans = 0;
for (int x = 0; x < n * 2 + 1; ++x) {
for (int y = 0; y < n * 2 + 1; ++y) {
if (g[x][y] == '0' || used[x][y]) {
continue;
}
ans++;
y_combinator([&](auto dfs, int i, int j) -> void {
used[i][j] = 1;
if (i + 1 < n * 2 + 1 && g[i + 1][j] == '1' && !used[i + 1][j]) {
dfs(i + 1, j);
}
if (j + 1 < n * 2 + 1 && g[i][j + 1] == '1' && !used[i][j + 1]) {
dfs(i, j + 1);
}
if (i && g[i - 1][j] == '1' && !used[i - 1][j]) {
dfs(i - 1, j);
}
if (j && g[i][j - 1] == '1' && !used[i][j - 1]) {
dfs(i, j - 1);
}
})(x, y);
}
}
string r = string(100, '0');
for (int i = 0; i < 20; ++i) {
if (ans & (1 << i)) {
r[i] = '1';
}
}
return r;
}
vector<string> g(3 + k * 2, string(3 + k * 2, '0'));
int kek = 0;
for (int x = 0; x < 3; ++x) {
for (int y = 0; y < 3; ++y) {
int p = 0;
for (int i = x; i < x + 3 + (k - 1) * 2; i += 2) {
for (int j = y; j < y + 3 + (k - 1) * 2; j += 2) {
g[i][j] = a[x][y][p];
p++;
}
}
}
}
string r = string(100, '0');
int p = 0;
for (int i = 0; i < 3 + k * 2; i += 2) {
for (int j = 0; j < 3 + k * 2; j += 2) {
r[p] = g[i][j];
p++;
}
}
return r;
}
Compilation message (stderr)
mars.cpp: In function 'std::string process(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:65:9: warning: unused variable 'kek' [-Wunused-variable]
65 | int kek = 0;
| ^~~
# | 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... |