답안 #403369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403369 2021-05-13T05:52:36 Z Haruto810198 무지개나라 (APIO17_rainbow) C++17
12 / 100
74 ms 6852 KB
#include <iostream>
#include "rainbow.h"

using namespace std;

#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,2,C,1){
            if(grid[j][i]==0 and grid[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[R][bc] - idx[R][ac];
    if(grid[R][ac]==0) ret++;

    return ret;

}

# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 66 ms 6832 KB Output is correct
4 Correct 70 ms 6696 KB Output is correct
5 Correct 66 ms 6724 KB Output is correct
6 Correct 74 ms 6692 KB Output is correct
7 Correct 65 ms 6804 KB Output is correct
8 Correct 71 ms 6724 KB Output is correct
9 Correct 68 ms 6708 KB Output is correct
10 Correct 68 ms 6684 KB Output is correct
11 Correct 65 ms 6704 KB Output is correct
12 Correct 57 ms 6776 KB Output is correct
13 Correct 60 ms 6740 KB Output is correct
14 Correct 59 ms 6768 KB Output is correct
15 Correct 59 ms 6812 KB Output is correct
16 Correct 67 ms 6852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Runtime error 5 ms 5324 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -