Submission #403365

# Submission time Handle Problem Language Result Execution time Memory
403365 2021-05-13T05:43:20 Z Haruto810198 Land of the Rainbow Gold (APIO17_rainbow) C++17
0 / 100
2 ms 460 KB
#include <iostream>
#include "rainbow.h"

#define FOR(i,l,r,d) for(int i=(l); i<=(r); i+=(d))

int grid[4][200001];
int idx[4][200001];

void init(int R, int C, int sr, int sc, int M, char *S) {

    /// 0=land 1=river

    FOR(i,1,R,1){
        FOR(j,1,C,1){
            grid[i][j] = 0;
        }
    }
    grid[sr][sc] = 1;

    int rptr=sr, cptr=sc;
    FOR(i,0,M-1,1){
        if(S[i]=='E') cptr++;
        if(S[i]=='W') cptr--;
        if(S[i]=='N') rptr--;
        if(S[i]=='S') rptr++;
        grid[rptr][cptr] = 1;
    }

    FOR(i,1,C,1){
        if(grid[1][i]==1 and grid[2][i]==1){
            grid[3][i] = 1;
        }
        else{
            grid[3][i] = 0;
        }
    }

    FOR(j,1,3,1){
        if(grid[j][1]==1){
            idx[j][1] = 0;
        }
        else{
            idx[j][1] = 1;
        }
        FOR(i,1,C,1){
            if(idx[j][i]==0 and idx[j][i-1]==1){
                idx[j][i] = idx[j][i-1] + 1;
            }
            else{
                idx[j][i] = idx[j][i-1];
            }
        }
    }

}

int colour(int ar, int ac, int br, int bc) {

    int R;
    if(ar==1 and br==2){
        R=3;
    }
    else{
        R=ar;
    }

    int ret = idx[bc] - idx[ac];
    if(grid[R][ac]==1) ret++;

    return ret;

}

# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -