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>
#include "mars.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
const int N=50;
char g[N][N];
bool used[N][N];
int ans=0,sz;
vector<int>dx={-1,1,0,0};
vector<int>dy={0,0,-1,1};
void dfs(int i,int j){
used[i][j]=true;
for(int k=0;k<4;k++){
int ni=i+dx[k],nj=j+dy[k];
if(ni<0||nj<0||ni>=sz||nj>=sz||g[ni][nj]=='0'||used[ni][nj]) continue;
dfs(ni,nj);
}
}
string process(vector<vector<string>>a,int i,int j,int k,int n){
sz=n*2+1;
if(n==1){
for(int i=0;i<=2;i++){
for(int j=0;j<=2;j++){
g[i][j]=a[i][j][0];
}
}
for(int i=0;i<=2;i++){
for(int j=0;j<=2;j++){
if(!used[i][j]&&g[i][j]=='1'){
ans++;
dfs(i,j);
}
}
}
string s(100,'0');
int cur=0;
while(ans){
if(ans&1){
s[cur]='1';
}
cur++;
ans>>=1;
}
return s;
}
else{
if(k==0){
string s(100,'0');
int cur=0;
for(int i=0;i<=2;i++){
for(int j=0;j<=2;j++){
s[cur++]=a[i][j][0];
}
}
return s;
}
else{
for(int i=0;i<=2;i++){
for(int j=0;j<=2;j++){
int cur=0;
for(int l=i;l<=i+2;l++){
for(int r=j;r<=j+2;r++){
g[l][r]=a[i][j][cur++];
}
}
}
}
ans=0;
for(int i=0;i<=4;i++){
for(int j=0;j<=4;j++){
if(!used[i][j]&&g[i][j]=='1'){
ans++;
dfs(i,j);
}
}
}
string s(100,'0');
int cur=0;
while(ans){
if(ans&1){
s[cur]='1';
}
cur++;
ans>>=1;
}
return s;
}
}
}
# | 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... |