답안 #403336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403336 2021-05-13T04:09:50 Z wiwiho 무지개나라 (APIO17_rainbow) C++14
12 / 100
85 ms 6468 KB
#include "rainbow.h"

#include <bits/stdc++.h>

#define mp make_pair
#define F first
#define S second
#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n"; \
}

using namespace std;

using pii = pair<int, int>;

vector<vector<bool>> g;
vector<vector<int>> vst;

int n, m;

vector<int> all, up, down;

void init(int R, int C, int sr, int sc, int M, char *S) {
    n = R; m = C;

    assert(n == 2);

    g.resize(n + 2, vector<bool>(m + 2));
    g[sr][sc] = true;
    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++;
        g[sr][sc] = true;
    }

    all.resize(m + 1);
    up.resize(m + 1);
    down.resize(m + 1);

    for(int i = 1; i <= m; i++){
        if(!g[1][i] && g[1][i - 1]){
            up[i] = 1;
            if(g[2][i] || g[2][i - 1]){
                all[i] = 1;
            }
        }
        if(!g[2][i] && g[2][i - 1]){
            down[i] = 1;
            if(g[1][i] || g[1][i - 1]){
                all[i] = 1;
            }
        }

        up[i] += up[i - 1];
        down[i] += down[i - 1];
        all[i] += all[i - 1];
    }
    
}


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

    if(br == 1){
        return up[bc] - up[ac] + !g[1][ac];
    }
    if(ar == 2){
        return down[bc] - down[ac] + !g[2][ac];
    }

    return all[bc] - all[ac] + (!g[1][ac] || !g[2][ac]);
}

# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 85 ms 6164 KB Output is correct
4 Correct 69 ms 6396 KB Output is correct
5 Correct 64 ms 6324 KB Output is correct
6 Correct 69 ms 6388 KB Output is correct
7 Correct 64 ms 6348 KB Output is correct
8 Correct 64 ms 6468 KB Output is correct
9 Correct 63 ms 6396 KB Output is correct
10 Correct 64 ms 6368 KB Output is correct
11 Correct 82 ms 6308 KB Output is correct
12 Correct 61 ms 6340 KB Output is correct
13 Correct 60 ms 6436 KB Output is correct
14 Correct 58 ms 6340 KB Output is correct
15 Correct 74 ms 6376 KB Output is correct
16 Correct 67 ms 6392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -