답안 #983482

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
983482 2024-05-15T14:33:41 Z stegatxins0 무지개나라 (APIO17_rainbow) C++17
0 / 100
2 ms 2792 KB
#include <bits/stdc++.h>
using namespace std;
#include "rainbow.h"

#ifdef DEBUG
#include "debug.cpp"
#else
#define dbg(...)
#define dbgarr(...)
#endif

const int mxN = 1001;
bool river[mxN][mxN];

// {{{ HASHMAP
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

struct chash {
    const uint64_t C = (long long)(4e18 * acos(0)) | 71;
	const uint32_t RANDOM =
	    chrono::steady_clock::now().time_since_epoch().count();
	size_t operator()(uint64_t x) const {
		return __builtin_bswap64((x ^ RANDOM) * C);
	}
};
// }}}

int R,C;
int ps[3][mxN], ss[3][mxN];

void init(int _R, int _C, int sr, int sc, int M, char *S) {
    R = _R, C = _C;
    memset(river,0,sizeof(river));
    memset(ss,0,sizeof(ss));
    memset(ps,0,sizeof(ps));
    int y = sr, x = sc;
    gp_hash_table<char, pair<int,int>> mp; // dy, dx;

    mp['N'] = {-1, 0};
    mp['S'] = {1, 0};
    mp['W'] = {0, -1};
    mp['E'] = {0, 1};

    river[y][x] = 1;
    for(int i=0; i<M; i++){
        y += mp[S[i]].first;
        x += mp[S[i]].second;
        river[y][x] = 1;
    }

    for(int i=1; i<=R; i++){
        for(int j=2; j<=C; j++){
            ps[i][j] = ps[i][j-1];
            ss[i][j] = ss[i][j-1];
            if(!river[i][j] && river[i][j-1]){ps[i][j]++;}
            if(river[i][j] && !river[i][j-1]){ss[i][j]++;}
        }
    }
    dbgarr(river[1], C+1);

    for(int i=2; i<=C; i++){
        ps[0][i] = ps[0][i-1];
        if( (!river[1][i] || !river[2][i]) && (river[1][i-1] && river[2][i-1])){ps[0][i]++;}

        ss[0][i] = ss[0][i-1];
        if( (river[1][i] && river[2][i]) && (!river[1][i-1] || !river[2][i-1])){ss[0][i]++;}
    }

    dbgarr(ps[1], C+1);
    dbgarr(ss[1], C+1);

}

int colour(int ar, int ac, int br, int bc) {
    if(ar != br){
        return ps[0][bc] - ss[0][ac];
    }
    return ps[ar][bc] - ss[ar][ac];
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Incorrect 1 ms 1372 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Runtime error 2 ms 2792 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -