#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vll vector<ll>
#define pll pair<ll,ll>
#define F first
#define S second
vll v[500];
ll pass[500][500];
pll d[4]={{0,1},{1,0},{-1,0},{0,-1}};
void bfs(ll x,pll y){
queue<pll> q;
q.push(y);
pass[y.F][y.S]=1;
while(!q.empty()){
pll u=q.front();q.pop();
//cout<<u.F<<" "<<u.S<<"\n";
for(auto d1 : d){
pll w=u;
w.F+=d1.F;
w.S+=d1.S;
if(min(w.F,w.S)<0 || max(w.F,w.S)>=x)continue;
//cout<<"\t"<<w.F<<" "<<w.S<<":OK?\n";
//cout<<"\t"<<d1.F<<" "<<d1.S<<":OK?\n";
if(pass[w.F][w.S]==0 && v[w.F][w.S]==1){
q.push(w);
// cout<<"\t"<<w.F<<" "<<w.S<<"\n";
pass[w.F][w.S]=1;
}
}
}
}
/*
1
1
*/
/*
3
3
1 1 1 1 1 0 0
0 0 0 0 0 0 0
0 0 0 0 0 1 0
1 1 1 0 0 0 0
1 0 1 0 0 0 1
1 1 1 1 1 1 1
0 0 0 0 0 0 0
2
1 1 1 0 0
0 0 0 1 1
1 1 0 0 0
0 0 0 1 1
0 1 0 0 0
1
1 0 0
1 1 0
0 0 1
*/
std::string process(std::vector <std::vector<std::string>> a, int I, int J, int k, int n)
{
// cout<<"\n"<<I<<" "<<J<<":";
ll vb=2*k+1;
ll b=2*(k+1)+1;
string s={};
if(k==n-1){
for(int i=0;i<b;i++){
v[i].assign(b,0LL);
// cout<<'\n';
for(int j=0;j<b;j++){
ll bi=0,bj=0;
if(i>=vb)bi=i-vb+1;
if(j>=vb)bj=j-vb+1;
ll d=(i-bi)*vb+j-bj;
v[i][j]=a[bi][bj][d]-'0';
// cout/*<<i<<" "<<j<<":"<<bi<<" "<<bj<<" "<<vb<<"->"<<d<<"="<<(i-bi)*vb+j-bj<<":"*/<<v[i][j]<<" ";
pass[i][j]=0;
}
}
ll r=0;
for(int i=0;i<b;i++){
for(int j=0;j<b;j++){
if(pass[i][j]==0 && v[i][j]==1){
// cout<<i<<" "<<j<<"\n";
r++;bfs(b,{i,j});
}
}
}
//cout<<r<<":)";
for(int i=0;i<100;i++){
if(i<=10 && (r&(1LL<<i)))s+='1';
else s+='0';
}
return s;
}
else{
for(int z=0;z<100;z++){
if(z<b*b){
ll i=z/b,j=z%b;
ll bi=0,bj=0;
if(i>=vb)bi=i-vb+1;
if(j>=vb)bj=j-vb+1;
ll d=(i-bi)*vb+j-bj;
s+=a[bi][bj][d];
// if(j==0)cout<<"\n";
// cout<<s[z]<<" ";
}
else s+='0';
}
return s;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2896 KB |
Output is correct |
2 |
Correct |
6 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3308 KB |
Output is correct |
4 |
Correct |
4 ms |
3260 KB |
Output is correct |
5 |
Correct |
2 ms |
3160 KB |
Output is correct |
6 |
Correct |
2 ms |
3016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2896 KB |
Output is correct |
2 |
Correct |
6 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3308 KB |
Output is correct |
4 |
Correct |
4 ms |
3260 KB |
Output is correct |
5 |
Correct |
2 ms |
3160 KB |
Output is correct |
6 |
Correct |
2 ms |
3016 KB |
Output is correct |
7 |
Correct |
8 ms |
2768 KB |
Output is correct |
8 |
Correct |
12 ms |
3160 KB |
Output is correct |
9 |
Correct |
8 ms |
3208 KB |
Output is correct |
10 |
Correct |
11 ms |
3080 KB |
Output is correct |
11 |
Correct |
9 ms |
2916 KB |
Output is correct |
12 |
Correct |
12 ms |
3048 KB |
Output is correct |
13 |
Correct |
8 ms |
3204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2896 KB |
Output is correct |
2 |
Correct |
6 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3308 KB |
Output is correct |
4 |
Correct |
4 ms |
3260 KB |
Output is correct |
5 |
Correct |
2 ms |
3160 KB |
Output is correct |
6 |
Correct |
2 ms |
3016 KB |
Output is correct |
7 |
Correct |
8 ms |
2768 KB |
Output is correct |
8 |
Correct |
12 ms |
3160 KB |
Output is correct |
9 |
Correct |
8 ms |
3208 KB |
Output is correct |
10 |
Correct |
11 ms |
3080 KB |
Output is correct |
11 |
Correct |
9 ms |
2916 KB |
Output is correct |
12 |
Correct |
12 ms |
3048 KB |
Output is correct |
13 |
Correct |
8 ms |
3204 KB |
Output is correct |
14 |
Incorrect |
2 ms |
476 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2896 KB |
Output is correct |
2 |
Correct |
6 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3308 KB |
Output is correct |
4 |
Correct |
4 ms |
3260 KB |
Output is correct |
5 |
Correct |
2 ms |
3160 KB |
Output is correct |
6 |
Correct |
2 ms |
3016 KB |
Output is correct |
7 |
Correct |
8 ms |
2768 KB |
Output is correct |
8 |
Correct |
12 ms |
3160 KB |
Output is correct |
9 |
Correct |
8 ms |
3208 KB |
Output is correct |
10 |
Correct |
11 ms |
3080 KB |
Output is correct |
11 |
Correct |
9 ms |
2916 KB |
Output is correct |
12 |
Correct |
12 ms |
3048 KB |
Output is correct |
13 |
Correct |
8 ms |
3204 KB |
Output is correct |
14 |
Incorrect |
2 ms |
476 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2896 KB |
Output is correct |
2 |
Correct |
6 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3308 KB |
Output is correct |
4 |
Correct |
4 ms |
3260 KB |
Output is correct |
5 |
Correct |
2 ms |
3160 KB |
Output is correct |
6 |
Correct |
2 ms |
3016 KB |
Output is correct |
7 |
Correct |
8 ms |
2768 KB |
Output is correct |
8 |
Correct |
12 ms |
3160 KB |
Output is correct |
9 |
Correct |
8 ms |
3208 KB |
Output is correct |
10 |
Correct |
11 ms |
3080 KB |
Output is correct |
11 |
Correct |
9 ms |
2916 KB |
Output is correct |
12 |
Correct |
12 ms |
3048 KB |
Output is correct |
13 |
Correct |
8 ms |
3204 KB |
Output is correct |
14 |
Incorrect |
2 ms |
476 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2896 KB |
Output is correct |
2 |
Correct |
6 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3308 KB |
Output is correct |
4 |
Correct |
4 ms |
3260 KB |
Output is correct |
5 |
Correct |
2 ms |
3160 KB |
Output is correct |
6 |
Correct |
2 ms |
3016 KB |
Output is correct |
7 |
Correct |
8 ms |
2768 KB |
Output is correct |
8 |
Correct |
12 ms |
3160 KB |
Output is correct |
9 |
Correct |
8 ms |
3208 KB |
Output is correct |
10 |
Correct |
11 ms |
3080 KB |
Output is correct |
11 |
Correct |
9 ms |
2916 KB |
Output is correct |
12 |
Correct |
12 ms |
3048 KB |
Output is correct |
13 |
Correct |
8 ms |
3204 KB |
Output is correct |
14 |
Incorrect |
2 ms |
476 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2896 KB |
Output is correct |
2 |
Correct |
6 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3308 KB |
Output is correct |
4 |
Correct |
4 ms |
3260 KB |
Output is correct |
5 |
Correct |
2 ms |
3160 KB |
Output is correct |
6 |
Correct |
2 ms |
3016 KB |
Output is correct |
7 |
Correct |
8 ms |
2768 KB |
Output is correct |
8 |
Correct |
12 ms |
3160 KB |
Output is correct |
9 |
Correct |
8 ms |
3208 KB |
Output is correct |
10 |
Correct |
11 ms |
3080 KB |
Output is correct |
11 |
Correct |
9 ms |
2916 KB |
Output is correct |
12 |
Correct |
12 ms |
3048 KB |
Output is correct |
13 |
Correct |
8 ms |
3204 KB |
Output is correct |
14 |
Incorrect |
2 ms |
476 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2896 KB |
Output is correct |
2 |
Correct |
6 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3308 KB |
Output is correct |
4 |
Correct |
4 ms |
3260 KB |
Output is correct |
5 |
Correct |
2 ms |
3160 KB |
Output is correct |
6 |
Correct |
2 ms |
3016 KB |
Output is correct |
7 |
Correct |
8 ms |
2768 KB |
Output is correct |
8 |
Correct |
12 ms |
3160 KB |
Output is correct |
9 |
Correct |
8 ms |
3208 KB |
Output is correct |
10 |
Correct |
11 ms |
3080 KB |
Output is correct |
11 |
Correct |
9 ms |
2916 KB |
Output is correct |
12 |
Correct |
12 ms |
3048 KB |
Output is correct |
13 |
Correct |
8 ms |
3204 KB |
Output is correct |
14 |
Incorrect |
2 ms |
476 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2896 KB |
Output is correct |
2 |
Correct |
6 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3308 KB |
Output is correct |
4 |
Correct |
4 ms |
3260 KB |
Output is correct |
5 |
Correct |
2 ms |
3160 KB |
Output is correct |
6 |
Correct |
2 ms |
3016 KB |
Output is correct |
7 |
Correct |
8 ms |
2768 KB |
Output is correct |
8 |
Correct |
12 ms |
3160 KB |
Output is correct |
9 |
Correct |
8 ms |
3208 KB |
Output is correct |
10 |
Correct |
11 ms |
3080 KB |
Output is correct |
11 |
Correct |
9 ms |
2916 KB |
Output is correct |
12 |
Correct |
12 ms |
3048 KB |
Output is correct |
13 |
Correct |
8 ms |
3204 KB |
Output is correct |
14 |
Incorrect |
2 ms |
476 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2896 KB |
Output is correct |
2 |
Correct |
6 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3308 KB |
Output is correct |
4 |
Correct |
4 ms |
3260 KB |
Output is correct |
5 |
Correct |
2 ms |
3160 KB |
Output is correct |
6 |
Correct |
2 ms |
3016 KB |
Output is correct |
7 |
Correct |
8 ms |
2768 KB |
Output is correct |
8 |
Correct |
12 ms |
3160 KB |
Output is correct |
9 |
Correct |
8 ms |
3208 KB |
Output is correct |
10 |
Correct |
11 ms |
3080 KB |
Output is correct |
11 |
Correct |
9 ms |
2916 KB |
Output is correct |
12 |
Correct |
12 ms |
3048 KB |
Output is correct |
13 |
Correct |
8 ms |
3204 KB |
Output is correct |
14 |
Incorrect |
2 ms |
476 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |