이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#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];
}
컴파일 시 표준 에러 (stderr) 메시지
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 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |