Submission #945117

# Submission time Handle Problem Language Result Execution time Memory
945117 2024-03-13T12:25:23 Z TAhmed33 Land of the Rainbow Gold (APIO17_rainbow) C++
0 / 100
1 ms 604 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
bool ok[51][51];
int dx[4] = {0, -1, 0, 1}, dy[4] = {1, 0, -1, 0};
int mny, mxy, mnx, mxx;
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;
    mny = mxy = y; mnx = mxx = x;
    for (int i = 0; i < z; i++) {
        x += dx[lk[s[i]]]; y += dy[lk[s[i]]];
        mny = min(mny, y);
        mxy = max(mxy, y);
        mnx = min(mnx, x);
        mxx = max(mxx, x);
        ok[x][y] = 0;
    }
}
int colour (int ar, int ac, int br, int bc) {
    ar--; br--; ac--; bc--;
    if (ar > br) swap(ar, br);
    if (ac > bc) swap(ac, bc);
    int ret = 0;
    for (int i = ar; i <= br; i++) {
        for (int j = ac; j <= bc; j++) {
            if (!ok[i][j]) continue;
            ret++;
        }
    }
    for (int i = ar; i <= br; i++) {
        for (int j = ac; j <= bc; j++) {
            if (!ok[i][j]) continue;
            if (i < br) if (ok[i + 1][j]) ret--;
            if (j < bc) if (ok[i][j + 1]) ret--;
            if (i < br && j < bc) if (ok[i + 1][j] && ok[i][j + 1] && ok[i + 1][j + 1]) ret++;
        }
    }
    if (ar > mnx && ac < mxx && br > mny && bc < mxy) ret++;
    return ret;
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 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 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -