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 pb push_back
#define ll long long int
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vpll vector<pair<long long int, long long int>>
#define pqpll priority_queue<pair<long long int, long long int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define mii map<int,int>
#define mll map<long long int, long long int>
#define mivi map<int,vector<int>>
#define f0r(i,n) for(int i=0;i<n;i++)
#define FOR(i,k,n) for(int i=k;i<n;i++)
using namespace std;
std::string process(std::vector <std::vector<std::string>> a, int i, int j, int k, int n)
{
string ret;
if(k == 0){
f0r(ii, 100)ret += '0';
f0r(ii, 3){
f0r(jj, 3){
ret[(i + ii) * (2*n+1) + (j + jj)] = a[ii][jj][0];
}
}
}
else{
ret = a[0][0];
f0r(ii, 3){
f0r(jj, 3){
f0r(cur, 100){
if(a[ii][jj][cur] == '1')ret[cur] = '1';
}
}
}
}
if(k == n-1){
//cout<<ret<<'\n';
int grid[2*n+1][2*n+1];
f0r(ii, 2*n+1){
f0r(jj, 2*n+1){
grid[ii][jj] = ret[ii * (2 * n + 1) + jj] - '0';
}
}
queue<pair<int,int>>q;
bool vis[2*n+1][2*n+1];
f0r(ii, 2*n+1)f0r(jj, 2*n+1)vis[ii][jj] = 0;
int ccs = 0;
f0r(ii, 2*n+1){
f0r(jj, 2*n+1){
if(grid[ii][jj] == 1 && !vis[ii][jj]){
ccs++;
q.push({ii, jj});
vis[ii][jj] = 1;
while(!q.empty()){
pii cur = q.front();
q.pop();
vpii nxt;
int a = cur.first;
int b = cur.second;
if(a != 0 && grid[a-1][b] == 1)nxt.pb({a-1, b});
if(a != 2*n && grid[a+1][b] == 1)nxt.pb({a+1, b});
if(b != 0 && grid[a][b-1] == 1)nxt.pb({a, b-1});
if(b != 2*n && grid[a][b+1] == 1)nxt.pb({a, b+1});
for(pii u : nxt){
if(vis[u.first][u.second])continue;
vis[u.first][u.second] = 1;
q.push({u.first, u.second});
}
}
}
}
}
//cout<<ccs<<'\n';
string ans = "";
f0r(ii, 20){
if(ccs & (1<<ii))ans += '1';
else ans+='0';
}
f0r(ii, 80)ans+='0';
return ans;
}
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... |