#include "mars.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
const int N=100;
int n,m;
bool vis[N][N];
char g[N][N];
vector<pair<int,int>> dir={{0,-1},{0,1},{1,0},{-1,0}};
bool valid(int x,int y)
{
return (0<=x and x<n and 0<=y and y<m and !vis[x][y] and g[x][y]=='1');
}
void dfs(int x,int y)
{
vis[x][y]=1;
for(auto [dx,dy]:dir)
{
if(valid(x+dx,y+dy))
{
dfs(x+dx,y+dy);
}
}
}
string process(vector <vector<string>> a, int i, int j, int k, int na)
{
m=n=(2*na)+1;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
vis[i][j]=0;
int side=(2*k+1); // for 0 this is side=1
{// Process information from the previous state
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
for(int pi=0;pi<side;pi++)
{
for(int pj=0;pj<side;pj++)
{
g[i+pi][j+pj]=a[i][j][(pi*side)+pj];
}
}
}
}
}
// cout<<"Hola "<<i<<' '<<j<<' '<<k<<na<<endl;
// cout<<"Grid i got Currently\n";
// for(int i=0;i<n;i++)
// {
// for(int j=0;j<m;j++)
// {
// cout<<g[i][j]<<' ';
// }
// cout<<endl;
// }
if((na-1)==k) // Last iteration
{
ll cp=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(!vis[i][j] and g[i][j]=='1')
{
cp++;
dfs(i,j);
}
}
}
string bp="";
while(cp>0)
{
bp+=char('0'+(cp%2));
cp/=2;
}
while(bp.size()<100)
bp+='0';
return bp;
}
else
{
// side+=2;
string tp="";
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
for(int pi=0;pi<side;pi++)
{
for(int pj=0;pj<side;pj++)
{
tp+=g[i+pi][j+pj];
}
}
}
}
while(tp.size()<100)
{
tp+='0';
}
return tp;
}
return string(100 ,'0');
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4116 KB |
Output is correct |
2 |
Correct |
3 ms |
4152 KB |
Output is correct |
3 |
Correct |
6 ms |
4136 KB |
Output is correct |
4 |
Correct |
4 ms |
3700 KB |
Output is correct |
5 |
Correct |
5 ms |
4164 KB |
Output is correct |
6 |
Correct |
5 ms |
3880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4116 KB |
Output is correct |
2 |
Correct |
3 ms |
4152 KB |
Output is correct |
3 |
Correct |
6 ms |
4136 KB |
Output is correct |
4 |
Correct |
4 ms |
3700 KB |
Output is correct |
5 |
Correct |
5 ms |
4164 KB |
Output is correct |
6 |
Correct |
5 ms |
3880 KB |
Output is correct |
7 |
Incorrect |
1 ms |
332 KB |
invalid len |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4116 KB |
Output is correct |
2 |
Correct |
3 ms |
4152 KB |
Output is correct |
3 |
Correct |
6 ms |
4136 KB |
Output is correct |
4 |
Correct |
4 ms |
3700 KB |
Output is correct |
5 |
Correct |
5 ms |
4164 KB |
Output is correct |
6 |
Correct |
5 ms |
3880 KB |
Output is correct |
7 |
Incorrect |
1 ms |
332 KB |
invalid len |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4116 KB |
Output is correct |
2 |
Correct |
3 ms |
4152 KB |
Output is correct |
3 |
Correct |
6 ms |
4136 KB |
Output is correct |
4 |
Correct |
4 ms |
3700 KB |
Output is correct |
5 |
Correct |
5 ms |
4164 KB |
Output is correct |
6 |
Correct |
5 ms |
3880 KB |
Output is correct |
7 |
Incorrect |
1 ms |
332 KB |
invalid len |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4116 KB |
Output is correct |
2 |
Correct |
3 ms |
4152 KB |
Output is correct |
3 |
Correct |
6 ms |
4136 KB |
Output is correct |
4 |
Correct |
4 ms |
3700 KB |
Output is correct |
5 |
Correct |
5 ms |
4164 KB |
Output is correct |
6 |
Correct |
5 ms |
3880 KB |
Output is correct |
7 |
Incorrect |
1 ms |
332 KB |
invalid len |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4116 KB |
Output is correct |
2 |
Correct |
3 ms |
4152 KB |
Output is correct |
3 |
Correct |
6 ms |
4136 KB |
Output is correct |
4 |
Correct |
4 ms |
3700 KB |
Output is correct |
5 |
Correct |
5 ms |
4164 KB |
Output is correct |
6 |
Correct |
5 ms |
3880 KB |
Output is correct |
7 |
Incorrect |
1 ms |
332 KB |
invalid len |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4116 KB |
Output is correct |
2 |
Correct |
3 ms |
4152 KB |
Output is correct |
3 |
Correct |
6 ms |
4136 KB |
Output is correct |
4 |
Correct |
4 ms |
3700 KB |
Output is correct |
5 |
Correct |
5 ms |
4164 KB |
Output is correct |
6 |
Correct |
5 ms |
3880 KB |
Output is correct |
7 |
Incorrect |
1 ms |
332 KB |
invalid len |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4116 KB |
Output is correct |
2 |
Correct |
3 ms |
4152 KB |
Output is correct |
3 |
Correct |
6 ms |
4136 KB |
Output is correct |
4 |
Correct |
4 ms |
3700 KB |
Output is correct |
5 |
Correct |
5 ms |
4164 KB |
Output is correct |
6 |
Correct |
5 ms |
3880 KB |
Output is correct |
7 |
Incorrect |
1 ms |
332 KB |
invalid len |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4116 KB |
Output is correct |
2 |
Correct |
3 ms |
4152 KB |
Output is correct |
3 |
Correct |
6 ms |
4136 KB |
Output is correct |
4 |
Correct |
4 ms |
3700 KB |
Output is correct |
5 |
Correct |
5 ms |
4164 KB |
Output is correct |
6 |
Correct |
5 ms |
3880 KB |
Output is correct |
7 |
Incorrect |
1 ms |
332 KB |
invalid len |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4116 KB |
Output is correct |
2 |
Correct |
3 ms |
4152 KB |
Output is correct |
3 |
Correct |
6 ms |
4136 KB |
Output is correct |
4 |
Correct |
4 ms |
3700 KB |
Output is correct |
5 |
Correct |
5 ms |
4164 KB |
Output is correct |
6 |
Correct |
5 ms |
3880 KB |
Output is correct |
7 |
Incorrect |
1 ms |
332 KB |
invalid len |
8 |
Halted |
0 ms |
0 KB |
- |