#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] = pr[i][j-1]+(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])+(c2>blocked[ind][pos2]);
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 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
46 ms |
4648 KB |
Output is correct |
4 |
Correct |
53 ms |
5676 KB |
Output is correct |
5 |
Correct |
55 ms |
5744 KB |
Output is correct |
6 |
Correct |
50 ms |
5428 KB |
Output is correct |
7 |
Correct |
53 ms |
5272 KB |
Output is correct |
8 |
Correct |
42 ms |
3916 KB |
Output is correct |
9 |
Correct |
53 ms |
5672 KB |
Output is correct |
10 |
Correct |
54 ms |
5772 KB |
Output is correct |
11 |
Correct |
52 ms |
5440 KB |
Output is correct |
12 |
Correct |
49 ms |
5124 KB |
Output is correct |
13 |
Correct |
44 ms |
5656 KB |
Output is correct |
14 |
Correct |
44 ms |
5728 KB |
Output is correct |
15 |
Correct |
45 ms |
5344 KB |
Output is correct |
16 |
Correct |
52 ms |
4840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
596 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 |
- |