Submission #1263267

#TimeUsernameProblemLanguageResultExecution timeMemory
1263267damoonLand of the Rainbow Gold (APIO17_rainbow)C++20
0 / 100
1 ms328 KiB
#include<bits/stdc++.h>
using namespace std;

const int L=60;
bool mark[L][L],W[L][L];

void init(int A,int B,int sx,int sy,int N,char* S){
    W[sx][sy] = 1;
    for(int i=0;i<N;i++){
        char c = S[i];
        if(c == 'N')
            sx--;
        if(c == 'S')
            sx++;
        if(c == 'W')
            sy--;
        if(c == 'E')
            sy++;
        W[sx][sy] = 1;
    }

    for(int i=1;i<=A;i++){
        for(int j=1;j<=B;j++){
            cout<<W[i][j];
        }
        cout<<endl;
    }
}

void dfs(int x,int y,int x1,int y1,int x2,int y2){
    if(x>x2 or x<x1 or y>y2 or y<y1 or mark[x][y] or W[x][y])
        return;
    mark[x][y] = 1;
    dfs(x+1,y,x1,y1,x2,y2);
    dfs(x,y+1,x1,y1,x2,y2);
    dfs(x-1,y,x1,y1,x2,y2);
    dfs(x,y-1,x1,y1,x2,y2);
}

int colour(int x1,int y1,int x2,int y2){
    for(int i=x1;i<=x2;i++){
        for(int j=y1;j<=y2;j++){
            mark[i][j] = 0;
        }
    }

    int ans = 0;
    for(int i=x1;i<=x2;i++){
        for(int j=y1;j<=y2;j++){
            if(!mark[i][j] and !W[i][j]){
                ans++;
                dfs(i,j,x1,y1,x2,y2);
            }
        }
    }
    return ans;
}

/*
int main(){
    int A,B,N,q,sx,sy;
    string inp;
    char I[100];

    cin>>A>>B>>N>>q;
    cin>>sx>>sy;
    if(N)
        cin>>inp;
    for(int i=0;i<N;i++){
        I[i] = inp[i];
    }

    init(A,B,sx,sy,N,I);
    for(int i=1;i<=q;i++){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        cout<<colour(x1,y1,x2,y2)<<endl;
    }
}
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...