#include <bits/stdc++.h>
#include "rainbow.h"
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repa(a,b) for(auto a: b)
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
bool river[3][200005]{};
int pref[3][200005]{};
void init(int R, int C, int sr, int sc, int M, char *S){
if(R!=2) exit(0);
river[sr][sc]=true;
rep(i,0,M){
if(S[i]=='N') sr--;
else if(S[i]=='S') sr++;
else if(S[i]=='W') sc--;
else sc++;
river[sr][sc]=true;
}
rep(i,1,C+1){
pref[0][i]+=pref[0][i-1];
pref[1][i]+=pref[1][i-1];
pref[2][i]+=pref[2][i-1];
if(river[1][i-1] && (!river[1][i])) pref[0][i]++;
if(river[2][i-1] && (!river[2][i])) pref[1][i]++;
if((river[1][i-1] && river[2][i-1]) && (!river[1][i] || !river[2][i])) pref[2][i]++;
}
}
int colour(int ar, int ac, int br, int bc){
int x, c;
if(br>ar) x=2;
else x=ar-1;
c=pref[x][bc]-pref[x][ac-1];
c+=((!river[ar][ac] || !river[br][ac]) && (!river[ar][ac-1] || !river[br][ac-1]));
return c;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
43 ms |
3484 KB |
Output is correct |
4 |
Correct |
44 ms |
3764 KB |
Output is correct |
5 |
Correct |
49 ms |
3540 KB |
Output is correct |
6 |
Correct |
52 ms |
3688 KB |
Output is correct |
7 |
Correct |
44 ms |
3676 KB |
Output is correct |
8 |
Correct |
42 ms |
3476 KB |
Output is correct |
9 |
Correct |
52 ms |
3672 KB |
Output is correct |
10 |
Correct |
60 ms |
3576 KB |
Output is correct |
11 |
Correct |
44 ms |
3652 KB |
Output is correct |
12 |
Correct |
42 ms |
3664 KB |
Output is correct |
13 |
Correct |
41 ms |
3664 KB |
Output is correct |
14 |
Correct |
43 ms |
3552 KB |
Output is correct |
15 |
Correct |
53 ms |
3604 KB |
Output is correct |
16 |
Correct |
45 ms |
3576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |