답안 #791774

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
791774 2023-07-24T09:47:48 Z Dan4Life 무지개나라 (APIO17_rainbow) C++17
0 / 100
1 ms 468 KB
//#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a), end(a)
const int mxN = (int)2e5+10;
vector<int> blocked[3];
int pr[3][mxN], a[2][mxN];

void init(int R, int C, int x, int y, int M, char *s) {
	x--,y--;
	for(int i = 0; i < M; i++){
		if(s[i]=='N') x--;
		if(s[i]=='S') x++;
		if(s[i]=='W') y--;
		if(s[i]=='E') y++;
		a[x][y] = 1;
	}
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < C; j++){
			if(a[i][j]) blocked[i].pb(j); 
			if(!i and a[0][j]&a[1][j]) blocked[2].pb(j); 
		}
	}
	for(int i = 0; i < 3; i++)
		for(int j = 1; j < sz(blocked[i]); j++)
			pr[i][j+1] = pr[i][j]+(blocked[i][j]!=blocked[i][j-1]+1);
}

int colour(int r1, int c1, int r2, int c2) {
	r1--,c1--,r2--,c2--; int ind = (r1==r2?r1:2);
	int pos1 = lower_bound(all(blocked[ind]),c1)-begin(blocked[ind]);
	int pos2 = upper_bound(all(blocked[ind]),c2)-begin(blocked[ind])-1;
	if(pos1>pos2) return 1;
	int tot = (c1<blocked[ind][pos1])+(c1<blocked[ind][pos1]);
	if(pos1==pos2) return tot+pr[ind][pos2]-pr[ind][pos1];
}

Compilation message

rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:38:1: warning: control reaches end of non-void function [-Wreturn-type]
   38 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -