Submission #57322

#TimeUsernameProblemLanguageResultExecution timeMemory
57322wilwxkLand of the Rainbow Gold (APIO17_rainbow)C++11
11 / 100
3047 ms7364 KiB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN=1000;
int v[MAXN][MAXN];
int marc[MAXN][MAXN];
int dx[]={0, -1, 0, 1};
int dy[]={1, 0, -1, 0};
int n, m;

void dfs(int ox, int oy) {
    //printf("%d %d\n", ox, oy);
    marc[ox][oy]=2;
    for(int i=0; i<4; i++) {
        int vx=ox+dx[i]; int vy=oy+dy[i];
        //printf(" viz : %d %d\n", vx, vy);
        if(vx<=0||vx>n) continue; if(vy<=0||vy>m) continue;
        if(marc[vx][vy]!=1||v[vx][vy]) continue;
        dfs(vx, vy);
    }
}

void init(int R, int C, int sr, int sc, int M, char *S) {
    int cx=sr, cy=sc; v[cx][cy]=1; n=R; m=C;
    for(int i=0; i<M; i++) {
        if(S[i]=='N') cx--;
        if(S[i]=='S') cx++;
        if(S[i]=='W') cy--;
        if(S[i]=='E') cy++;
        v[cx][cy]=1;
    }
}

int colour(int ar, int ac, int br, int bc) {
    for(int i=ar; i<=br; i++) for(int j=ac; j<=bc; j++) marc[i][j]=1;
    int resp=0;
    for(int i=ar; i<=br; i++) {
        for(int j=ac; j<=bc; j++) {
            if(marc[i][j]==2||v[i][j]) continue;
            dfs(i, j); resp++;
        }
    }
    for(int i=ar; i<=br; i++) for(int j=ac; j<=bc; j++) marc[i][j]=0;
    return resp;
    return 0;
}

Compilation message (stderr)

rainbow.cpp: In function 'void dfs(int, int)':
rainbow.cpp:18:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(vx<=0||vx>n) continue; if(vy<=0||vy>m) continue;
         ^~
rainbow.cpp:18:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
         if(vx<=0||vx>n) continue; if(vy<=0||vy>m) continue;
                                   ^~
#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...