Submission #1117111

# Submission time Handle Problem Language Result Execution time Memory
1117111 2024-11-22T20:34:58 Z Sofiatpc Land of the Rainbow Gold (APIO17_rainbow) C++14
11 / 100
10 ms 592 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) {
    marc[sr][sc] = 2;
    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 Correct 2 ms 336 KB Output is correct
2 Correct 4 ms 476 KB Output is correct
3 Correct 10 ms 336 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 508 KB Output is correct
11 Correct 8 ms 336 KB Output is correct
12 Correct 7 ms 336 KB Output is correct
13 Correct 6 ms 504 KB Output is correct
14 Correct 4 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 516 KB Output is correct
3 Runtime error 2 ms 592 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Runtime error 2 ms 592 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 4 ms 476 KB Output is correct
3 Correct 10 ms 336 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 508 KB Output is correct
11 Correct 8 ms 336 KB Output is correct
12 Correct 7 ms 336 KB Output is correct
13 Correct 6 ms 504 KB Output is correct
14 Correct 4 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 516 KB Output is correct
18 Runtime error 2 ms 592 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 4 ms 476 KB Output is correct
3 Correct 10 ms 336 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 508 KB Output is correct
11 Correct 8 ms 336 KB Output is correct
12 Correct 7 ms 336 KB Output is correct
13 Correct 6 ms 504 KB Output is correct
14 Correct 4 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 516 KB Output is correct
18 Runtime error 2 ms 592 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -