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 "mars.h"
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
int get(int i, int j, int n){
i /= 2;
j /= 2;
n = n / 2 + (n & 1);
return i * n + j;
}
string operator|(string x, string y){
for (int i = 0; i < 100; i++)
if (y[i] == '1')
x[i] = y[i];
return x;
}
std::string process(std::vector <std::vector<std::string>> a, int x, int y, int k, int n){
if (!k)
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
if (a[i][j][0] == '1'){
a[i][j][0] = '0';
a[i][j][get(x + i, y + j, n * 2 + 1)] = '1';
}
a[0][0] = a[0][0] | a[2][0] | a[0][2] | a[2][2];
if (k < n - 1)
return a[0][0];
n = n * 2 + 1;
a[0][1] = a[0][1] | a[2][1];
a[1][0] = a[1][0] | a[1][2];
bitset<48>land[48];
int h1[4]{1, -1, 0, 0};
int h2[4]{0, 0, 1, -1};
bool vis[48][48];
for (int i = 0; i < n; i++)
land[i].reset();
for (x = 0; x < 2; x++)
for (int y = 0; y < 2; y++)
for (int i = x; i < n; i += 2)
for (int j = y; j < n; j += 2)
if (a[x][y][get(i, j, n)] == '1')
land[i].set(j);
memset(vis, false, sizeof(vis));
queue<pii>s;
int ans = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (!vis[i][j] && land[i].test(j)){
ans++;
s.push({i, j});
vis[i][j] = true;
while (!s.empty()){
pii u = s.front();
s.pop();
for (int c = 0; c < 4; c++){
pii v = {u.fi + h1[c], u.se + h2[c]};
if (v.fi < 0 || v.fi >= n || v.se < 0 || v.se >= n || !land[v.fi].test(v.se) || vis[v.fi][v.se])
continue;
s.push(v);
vis[v.fi][v.se] = true;
}
}
}
string res;
res.resize(100, '0');
for (int i = 0; i < 15; i++)
if ((ans >> i) & 1)
res[i] = '1';
return res;
}
# | 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... |