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>
#define endl '\n'
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fo(i,n) for(auto i =0 ; i < n;i++)
#define fore(i,l,r) for(auto i = l; i < r;i++)
#define forex(i,r,l) for(auto i = r; i >= l; i--)
#define ffo(i,n) forex(i,n-1,0)
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define sz(x) (int)x.size()
#define gcd(a,b) __gcd(a,b)
#define vii vector<ii>
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<ll>;using ii = pair<ll,ll>;using mii = map<ll,ll>;
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
string process(vector<vector<string>> a,int x,int y,int ph,int n){
string res="";
fo(i,100)res+='0';
if(n>4)return res;
// if(ph == 0){
// fo(i, 3)
// fo(j, 3)
// res[(i*3) + j] = a[i][j][0];
// return res;
// }else{
int con = (ph +1 ) *2 + 1, con2 = con-2;
// cout<<con<<" "<<con2<<endl;
fo(i,con2){
fo(j, con2)
res[(i*con) + j] = a[0][0][(i*con2) + j];
res[(i*con) + con-2] = a[0][1][(i*con2) + con2 - 1];
res[(i*con) + con-1] = a[0][2][(i*con2) + con2 - 1];
}
// cout<<res<<endl;
fo(i,con2)
res[((con-2)*con) +i] = a[1][0][((con2-1)*con2) + i];
res[((con-2)*con) + con-2] = a[1][1][con2*con2 - 1];
res[((con-2)*con) + con-1] = a[1][2][con2*con2 - 1];
fo(i,con2)
res[((con-1)*con) + i] = a[2][0][((con2-1)*con2) + i];
res[((con-1)*con) + con-2] = a[2][1][con2*con2 - 1];
res[((con-1)*con) + con-1] = a[2][2][con2*con2 - 1];
// cout<<res<<endl;
if(ph == n-1){
int tot = 0;
vector<vi> vis(2*n+1, vi(2*n+1, 0));
fo(i,2*n+1){
fo(j,2*n+1){
if(vis[i][j])continue;
if(res[(i*con) + j] == '0') continue;
queue<ii> q;q.push({i,j});tot++;
vi dir = {0,-1,0,1,0};
while(!q.empty()){
auto where = q.front();q.pop();
fo(k,4){
int sr = where.f + dir[k], sc = where.s + dir[k+1];
if(sr<0 || sc<0 || sr>2*n || sc>2*n)continue;
if(vis[sr][sc])continue;
if(res[(sr*con) + sc] == '0')continue;
q.push({sr, sc});vis[sr][sc] = 1;
}
}
}
}
string ans = "";fo(i,100) ans+='0';
for(int bit =0;bit<=30;bit++)if(tot&(1<<bit))ans[bit] = '1';
return ans;
}
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... |