#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--; a[x][y]=1;
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==sz(blocked[ind]) or blocked[ind][pos1]>c2) return 1;
int tot = (c1<blocked[ind][pos1])+(c1<blocked[ind][pos1]);
return tot+pr[ind][pos2]-pr[ind][pos1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
712 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |