Submission #1117108

# Submission time Handle Problem Language Result Execution time Memory
1117108 2024-11-22T20:31:33 Z Sofiatpc Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
2 ms 336 KB
#include <bits/stdc++.h>
#include "rainbow.h"

using namespace std;

int marc[55][55], n1, n2,m1,m2;
int di[4] = {0,0,-1,1};
int dj[4] = {-1,1,0,0};

void init(int R, int C, int sr, int sc, int m, char *s) {
    for(int i = 0; i < m; i++){
        if(s[i] == 'N')sr--;
        else if(s[i] == 'S')sr++;
        else if(s[i] == 'W')sc--;
        else sc++;
        marc[sr][sc] = 2;
    }
}

void dfs(int i, int j){
    marc[i][j] = 1;
    for(int d = 0; d < 4; d++){
        int ni = i + di[d], nj = j + dj[d];
        if(ni < n1 || ni > n2 || nj < m1 || nj > m2 || marc[ni][nj])continue;
        dfs(ni,nj);
    }
}

int colour(int ar, int ac, int br, int bc) {
    for(int i = ar; i <= br; i++)
        for(int j = ac; j <= bc; j++)
            if(marc[i][j] != 2)marc[i][j] = 0;

    n1 = ar; n2 = br;
    m1 = ac; m2 = bc;

    int qtd = 0;
    for(int i = ar; i <= br; i++)
        for(int j = ac; j <= bc; j++)
            if(marc[i][j] == 0){
                qtd++;
                dfs(i,j);
            }
    return qtd;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -