Submission #1032975

# Submission time Handle Problem Language Result Execution time Memory
1032975 2024-07-24T11:29:46 Z irmuun Mars (APIO22_mars) C++17
0 / 100
1 ms 332 KB
#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 x=0;x<=2;x++){
            for(int y=0;y<=2;y++){
                g[x][y]=a[x][y][0];
            }
        }
        for(int x=0;x<=2;x++){
            for(int y=0;y<=2;y++){
                if(!used[x][y]&&g[x][y]=='1'){
                    ans++;
                    dfs(x,y);
                }
            }
        }
        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 x=0;x<=2;x++){
                for(int y=0;y<=2;y++){
                    s[cur++]=a[x][y][0];
                }
            }
            return s;
        }
        else{
            for(int x=0;x<=2;x++){
                for(int y=0;y<=2;y++){
                    int cur=0;
                    for(int l=x;l<=x+2;l++){
                        for(int r=y;r<=y+2;r++){
                            g[l][r]=a[x][y][cur++];
                        }
                    }
                }
            }
            ans=0;
            for(int x=0;x<sz;x++){
                for(int y=0;y<sz;y++){
                    if(!used[x][y]&&g[x][y]=='1'){
                        ans++;
                        dfs(x,y);
                    }
                }
            }
            string s(100,'0');
            int cur=0;
            while(ans){
                if(ans&1){
                    s[cur]='1';
                }
                cur++;
                ans>>=1;
            }
            return s;
        }
    }
}
/*
int main(){
    int n;
    cin>>n;
    string gate[n+1][n*2+2][n*2+2];
    for(int i=0;i<2*n+1;i++){
        for(int j=0;j<2*n+1;j++){
            cin>>gate[0][i][j];
            while(gate[0][i][j].size()<100){
                gate[0][i][j]+='0';
            }
        }
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<=2*(n-k-1);i++){
            for(int j=0;j<=2*(n-k-1);j++){
                gate[k+1][i][j]=process({
                    {gate[k][i+0][j+0],gate[k][i+0][j+1],gate[k][i+0][j+2]},
                    {gate[k][i+1][j+0],gate[k][i+1][j+1],gate[k][i+1][j+2]},
                    {gate[k][i+2][j+0],gate[k][i+2][j+1],gate[k][i+2][j+2]}
                    },i,j,k,n);
                //cout<<i<<' '<<j<<' '<<k<<' '<<gate[k+1][i][j]<<"\n";
            }
        }
    }
    cout<<gate[n][0][0]<<"\n";
}
*/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -