Submission #1117104

# Submission time Handle Problem Language Result Execution time Memory
1117104 2024-11-22T20:22:55 Z gustavo_d Land of the Rainbow Gold (APIO17_rainbow) C++17
11 / 100
12 ms 848 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;

map<char, pair<int, int>> ds;
pair<int, int> moves[4] = {
    {0, -1},
    {0, 1},
    {1, 0},
    {-1, 0},
};

bool mark[51][51];

int x, y;

void init(int R, int C, int sr, int sc, int M, char *S) {
    x=R; y=C;
    ds['N'] = {-1, 0};
    ds['S'] = {1, 0};
    ds['E'] = {0, 1};
    ds['W'] = {0, -1};
    for (int i=0; i<=50; i++) mark[i][0] = true;
    for (int i=0; i<=50; i++) mark[0][i] = true;
    mark[sr][sc] = true;
    // cout << sr << ' ' << sc << endl;
    for (int i=0; i<M; i++) {
        char c = S[i];
        sr += ds[c].first;
        sc += ds[c].second;
        mark[sr][sc] = true;
        // cout << sr << ' ' << sc << endl;
    }
}

bool tmp[51][51];
int lar, lac, lbr, lbc;
void dfs(int i, int j) {
    if (i < lar or j < lac or i > lbr or j > lbc or tmp[i][j]) return;
    tmp[i][j] = true;
    for (pair<int, int> d : moves) {
        dfs(i + d.first, j + d.second);
    }
}

int colour(int ar, int ac, int br, int bc) {
    lar = ar; lac = ac; lbr = br; lbc = bc;
    int cnt = 0;

    for (int i=1; i<=50; i++) {
        for (int j=1; j<=50; j++) {
            tmp[i][j] = mark[i][j];
        }
    }
    for (int r=ar; r<=br; r++) {
        for (int c=ac; c<=bc; c++) {
            if (!tmp[r][c]) {
                cnt++;
                dfs(r, c);
            }
        }
    }
    return cnt;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 4 ms 336 KB Output is correct
3 Correct 11 ms 504 KB Output is correct
4 Correct 12 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 444 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 516 KB Output is correct
12 Correct 8 ms 336 KB Output is correct
13 Correct 6 ms 336 KB Output is correct
14 Correct 4 ms 452 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 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Runtime error 1 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 336 KB Output is correct
3 Correct 11 ms 504 KB Output is correct
4 Correct 12 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 444 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 516 KB Output is correct
12 Correct 8 ms 336 KB Output is correct
13 Correct 6 ms 336 KB Output is correct
14 Correct 4 ms 452 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 336 KB Output is correct
18 Runtime error 2 ms 848 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 336 KB Output is correct
3 Correct 11 ms 504 KB Output is correct
4 Correct 12 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 444 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 11 ms 516 KB Output is correct
12 Correct 8 ms 336 KB Output is correct
13 Correct 6 ms 336 KB Output is correct
14 Correct 4 ms 452 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 336 KB Output is correct
18 Runtime error 2 ms 848 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -