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>
using namespace std;
int xx[4] = {1 , -1 , 0 , 0};
int yy[4] = {0 , 0 , -1 , 1};
std::string process(std::vector <std::vector<std::string>> a, int i, int j, int k, int n)
{
string ret(100 , '0');
int N = 2*n + 1;
for(int x = i ; x <= i + 2 ; x++)
{
for(int y = j ; y <= j + 2 ; y++)
{
if(k == 0)
{
swap(a[x - i][y - j][0] , a[x - i][y - j][N * x + y]);
}
for(int z = 0 ; z < 100 ; z++)
{
ret[z]|=a[x - i][y - j][z];
}
}
}
if(k == n - 1)
{
vector<vector<bool>> vis(2 * n +1 , vector<bool>(2 * n + 1));
int cnt = 0;
auto dfs = [&](int x , int y , auto &&dfs)->void
{
if(vis[x][y])
{
return ;
}
cnt++;
vis[x][y] = 1;
for(int K = 0 ; K < 4 ; K++)
{
int nx = x + xx[K] , ny = y + yy[K];
if(nx >= 0 && ny >= 0 && nx < N && ny < N && ret[nx * N + ny] == '1')
{
dfs(nx , ny, dfs);
}
}
};
int mx = 0;
for(int x = 0 ;x < N ; x++)
{
for(int y = 0 ; y < N ; y++)
{
if(!vis[x][y] && ret[N * x + y] == '1')
{
cnt = 0;
dfs(x , y , dfs);
mx = max(mx , cnt);
}
}
}
vis = vector<vector<bool>> (2*n + 1 , vector<bool>(2 * n +1));
cnt = 0;
int ans = 0;
for(int x = 0 ;x < N ; x++)
{
for(int y = 0 ; y < N ; y++)
{
if(!vis[x][y] && ret[N * x + y] == '1')
{
cnt = 0;
dfs(x , y , dfs);
if(mx == cnt)
{
ans++;
}
}
}
}
string s(100 , '0');
for(int x = 0 ; x < 20; x++)
{
if((1<<x) & ans)
{
s[x] = '1';
}
}
return s;
}
return ret;
}
# | 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... |