#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)
{
if(na==1)
{
n=a[0].size();
m=a.size();
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
g[i][j]=a[i][j][0];
}
}
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;
// We got the whole grid so just run dfs and get the connected components
}
else if(na==2)
{
if(k==0)
{
string tp="";
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
tp+=a[i][j][0];
}
}
while(tp.size()<100)
{
tp+='0';
}
return tp;
}
else// k==1
{
n=(2*na)+1;
m=n;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
for(int p=0;p<9;p++)
{
g[i+(p/3)][j+(p%3)]=a[i][j][p];
}
}
}
// cout<<"Grid i made\n";
// for(int i=0;i<n;i++)
// {
// for(int j=0;j<m;j++)
// {
// cout<<g[i][j]<<' ';
// }
// cout<<endl;
// }
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;
}
}
return string(100 ,'0');
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |