Submission #1117176

# Submission time Handle Problem Language Result Execution time Memory
1117176 2024-11-22T21:29:13 Z Sofiatpc Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
#include "rainbow.h"

using namespace std;

int marc[5][200005], sum[5][200005],che[5], f, fl, fr, le, ld;

void init(int r, int c, int sr, int sc, int m, char *s) {
    marc[sr][sc] = 1;
    le = sc; ld = sc; che[sr] = 1;
    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++;

        che[sr] = 1;
        le = min(le,sc); ld = max(ld,sc);
        marc[sr][sc] = 1;
    }
    marc[1][0] = 1; marc[2][0] = 1;

    for(int i = 1; i <= r; i++){
        for(int j = 1; j <= c; j++){
            sum[i][j] = sum[i][j-1];
            if(marc[i][j-1] == 1 && marc[i][j] == 0)sum[i][j]++;
        }
    }

    if(che[1] == 0 || che[2] == 0){
        if(che[1] != 0)f = 1;
        else f = 2;

        int l = 0;
        for(int j = 1; j <= c; j++){
            if(marc[f][j] == 1 && l == 0)l = j;
            if(marc[f][j] == 0 && l != 0){
                fl = l; fr = j-1;
                l = 0;
            }
        }
        if(l != 0){
            fl = l;
            fr = c;
        }
    }
}

int colour(int ar, int ac, int br, int bc) {
    if(f){
        if(ar != br)return 1;
        if(ar != f)return 1;
        if(ac < fl && fr < bc)return 2;
        return 1;
    }

    int ans = 0;
    if(ar == 1){
        ans += sum[1][bc] - sum[1][ac-1];
        if(marc[1][ac-1] == 0 && marc[1][ac] == 0)ans++;
    }
    if(br == 2){
        ans += sum[2][bc] - sum[2][ac-1];
        if(marc[2][ac-1] == 0 && marc[2][ac] == 0)ans++;
    }

    if(ar != br && ac < le)ans--;
    if(ar != br && bc > ld)ans--;
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -