답안 #409185

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
409185 2021-05-20T10:35:03 Z cheissmart 무지개나라 (APIO17_rainbow) C++14
0 / 100
15 ms 8900 KB
#ifndef CHEISSMART
#include "rainbow.h"
#endif
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
	cerr << to_string(h);
	if(sizeof ...(t)) cerr << ", ";
	DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif

const int INF = 1e9 + 7, N = 2e5 + 7;

int di[] = {1, -1, 0, 0}, dj[] = {0, 0, 1, -1};

V<pi> bad;
int R, C;
int a[2][N], nw[3][N], nwp[3][N];

void init(int R, int C, int sr, int sc, int M, char *S) {
	::R = R, ::C = C;
	bad.EB(sr - 1, sc - 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++;
		bad.EB(sr - 1, sc - 1);
	}
	sort(ALL(bad));
	bad.resize(unique(ALL(bad)) - bad.begin());
	for(pi p:bad) a[p.F][p.S] = 1;
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < N; j++) {
			if(a[i][j] == 0 && (j == 0 || a[i][j - 1] == 1)) 
				nw[i][j] = 1;
			nwp[i][j] = nw[i][j] + (j ? nwp[i][j - 1] : 0);
		}
	}
	for(int j = 0; j < N; j++) {
		if(a[0][j] == 0 || a[1][j] == 0) {
			nw[2][j] = 1;
			if(j && a[0][j] ==0 && a[0][j - 1] == 0)
				nw[2][j] = 0;
			if(j && a[1][j] ==0 && a[1][j - 1] == 0)
				nw[2][j] = 0;
		}
		nwp[2][j] = nw[2][j] + (j ? nwp[2][j - 1] : 0);
	}
}

int colour(int ar, int ac, int br, int bc) {
	ar--, ac--, br--, bc--;
	if(bc == ac) {
		return a[ar][ac] == 0 || a[br][ac] == 0;
	}
	int res = 0;
	if(ac == bc) {
		res += nwp[ac][br] - nwp[ac][ar];
		if(a[ac][ar] == 0 && nw[ac][ar + 1] == 0)
			res++;
	} else {
		res += nwp[2][br] - nwp[2][ar];
		if(a[ac][ar] == 0 || a[bc][ar] == 0)
			if(nw[2][ar + 1] == 0)
				res++;
	}
	return res;
}


# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3404 KB Output is correct
2 Correct 4 ms 3404 KB Output is correct
3 Runtime error 15 ms 8900 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3404 KB Output is correct
2 Runtime error 7 ms 2368 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -