Submission #945100

# Submission time Handle Problem Language Result Execution time Memory
945100 2024-03-13T11:57:20 Z TAhmed33 Land of the Rainbow Gold (APIO17_rainbow) C++
11 / 100
10 ms 860 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
bool ok[51][51];
bool vis[51][51];
int dx[4] = {0, -1, 0, 1}, dy[4] = {1, 0, -1, 0};
map <char, int> lk = {
    {'E', 0},
    {'N', 1},
    {'W', 2},
    {'S', 3}
};
int n, m;
void init (int N, int M, int x, int y, int z, char *s) {
    n = N; m = M;
    x--; y--;
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) ok[i][j] = 1;
    ok[x][y] = 0;
    for (int i = 0; i < z; i++) {
        x += dx[lk[s[i]]]; y += dy[lk[s[i]]];
        ok[x][y] = 0;
    }
}
void dfs (int x, int y, int a, int b, int c, int d) {
    vis[x][y] = 1;
    for (int i = 0; i < 4; i++) {
        int g = x + dx[i], h = y + dy[i];
        if (g >= a && g <= b && h >= c && h <= d && ok[g][h] && !vis[g][h]) {
            dfs(g, h, a, b, c, d);
        }
    }
}
int colour (int ar, int br, int ac, int bc) {
    ar--; br--; ac--; bc--;
    for (int i = ar; i <= ac; i++) {
        for (int j = br; j <= bc; j++) {
            vis[i][j] = 0;
        }
    }
    if (ar > ac) swap(ar, ac);
    if (br > bc) swap(br, bc);
    int ret = 0;
    for (int i = ar; i <= ac; i++) {
        for (int j = br; j <= bc; j++) {
            if (!ok[i][j]) continue;
            if (!vis[i][j]) {
                dfs(i, j, ar, ac, br, bc);
                ret++;
            }
        }
    }
    return ret;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 10 ms 600 KB Output is correct
4 Correct 10 ms 604 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 10 ms 576 KB Output is correct
12 Correct 8 ms 348 KB Output is correct
13 Correct 9 ms 456 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 1 ms 860 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 10 ms 600 KB Output is correct
4 Correct 10 ms 604 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 10 ms 576 KB Output is correct
12 Correct 8 ms 348 KB Output is correct
13 Correct 9 ms 456 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Runtime error 1 ms 860 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 10 ms 600 KB Output is correct
4 Correct 10 ms 604 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 10 ms 576 KB Output is correct
12 Correct 8 ms 348 KB Output is correct
13 Correct 9 ms 456 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Runtime error 1 ms 860 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -