Submission #731974

# Submission time Handle Problem Language Result Execution time Memory
731974 2023-04-28T07:54:09 Z Josia Land of the Rainbow Gold (APIO17_rainbow) C++14
11 / 100
3000 ms 1048576 KB
#include "rainbow.h"

#include <bits/stdc++.h>

using namespace std;


int R, C;
vector<vector<bool>> riv;

map<char, pair<int, int>> dir;


void init(signed r, signed c, signed sr, signed sc, signed M, char *S) {
    dir['N'] = {-1, 0};
    dir['S'] = {1, 0};
    dir['W'] = {0, -1};
    dir['E'] = {0, 1};


    R = r; C = c;
    riv.assign(R, vector<bool>(C));

    pair<int, int> pos = {sr-1, sc-1};
    riv[pos.first][pos.second]=1;


    for (int i=0;i<M;i++) {
        pos.first += dir[S[i]].first;
        pos.second += dir[S[i]].second;

        riv[pos.first][pos.second]=1;
    }
}



vector<vector<bool>> vis;

bool dfs(pair<int, int> v, int ar, int ac, int br, int bc) {
    if (v.first < ar || v.first > br) return 0;
    if (v.second < ac || v.second > bc) return 0;
    if (vis[v.first][v.second]) return 0;
    if (riv[v.first][v.second]) return 0;
    vis[v.first][v.second] = 1;


    for (auto i: dir) {
        dfs({v.first+i.second.first, v.second + i.second.second}, ar, ac, br, bc);
    }

    return 1;
}


signed colour(signed ar, signed ac, signed br, signed bc) {
    ar--;ac--;br--;bc--;

    vis.assign(R, vector<bool>(C));

    int res = 0;

    for (int i = ar; i<=br; i++) {
        for (int j = ac; j<=bc; j++) {
            res += dfs({i, j}, ar, ac, br, bc);
        }
    }

    return res;

}

# Verdict Execution time Memory Grader output
1 Correct 4 ms 320 KB Output is correct
2 Correct 19 ms 316 KB Output is correct
3 Correct 41 ms 488 KB Output is correct
4 Correct 37 ms 500 KB Output is correct
5 Correct 17 ms 404 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 36 ms 444 KB Output is correct
12 Correct 28 ms 436 KB Output is correct
13 Correct 21 ms 340 KB Output is correct
14 Correct 17 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Execution timed out 3062 ms 22356 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 592 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 320 KB Output is correct
2 Correct 19 ms 316 KB Output is correct
3 Correct 41 ms 488 KB Output is correct
4 Correct 37 ms 500 KB Output is correct
5 Correct 17 ms 404 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 36 ms 444 KB Output is correct
12 Correct 28 ms 436 KB Output is correct
13 Correct 21 ms 340 KB Output is correct
14 Correct 17 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Execution timed out 3038 ms 9560 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 320 KB Output is correct
2 Correct 19 ms 316 KB Output is correct
3 Correct 41 ms 488 KB Output is correct
4 Correct 37 ms 500 KB Output is correct
5 Correct 17 ms 404 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 36 ms 444 KB Output is correct
12 Correct 28 ms 436 KB Output is correct
13 Correct 21 ms 340 KB Output is correct
14 Correct 17 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Execution timed out 3038 ms 9560 KB Time limit exceeded
19 Halted 0 ms 0 KB -