#include <bits/stdc++.h>
#include "rainbow.h"
using namespace std;
int marc[5][200005], sum[5][200005], f, fl, fr, le, ld;
void init(int r, int c, int sr, int sc, int m, char *s) {
marc[sr][sc] = 2;
le = sc; ld = sc;
for(int i = 0; i < m; i++){
if(s[i] == 'N')sr--;
else if(s[i] == 'S')sr++;
else if(s[i] == 'W')sc--;
else sc++;
le = min(le,sc); ld = max(ld,sc);
marc[sr][sc] = 1;
}
marc[1][0] = 1; marc[2][0] = 1;
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
sum[i][j] = sum[i][j-1];
if(marc[i][j-1] == 1 && marc[i][j] == 0)sum[i][j]++;
}
}
if(sum[1][c] == 0 || sum[2][c] == 0){
if(sum[1][c] != 0)f = 1;
else f = 2;
int l = 0;
for(int j = 1; j <= c; j++){
if(marc[f][j] == 1 && l == 0)l = j;
if(marc[f][j] == 0 && l == 1){
fl = l; fr = j-1;
l = 0;
}
}
if(l != 0){
fl = l;
fr = c;
}
}
}
int colour(int ar, int ac, int br, int bc) {
if(f){
if(ar != br)return 1;
if(ar != f)return 1;
if(ac < fl && fr < bc)return 2;
return 1;
}
int ans = 0;
if(ar == 1){
ans += sum[1][bc] - sum[1][ac-1];
if(marc[1][ac-1] == 0 && marc[1][ac] == 0)ans++;
}
if(br == 2){
ans += sum[2][bc] - sum[2][ac-1];
if(marc[2][ac-1] == 0 && marc[2][ac] == 0)ans++;
}
if(ar != br && ac < le)ans--;
if(ar != br && bc > ld)ans--;
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |