#include <bits/stdc++.h>
#include "rainbow.h"
using namespace std;
vector<vector<bool>> land;
vector<int> S1, S2, S12;
void init(int R, int C, int sr, int sc, int M, char *S){
sr--;
sc--;
land = vector<vector<bool>>(R, vector<bool>(C, true));
int x = sr, y = sc;
land[x][y] = false;
for (int i = 0; i < M; i++){
if (S[i] == 'N'){
x--;
}
if (S[i] == 'S'){
x++;
}
if (S[i] == 'E'){
y++;
}
if (S[i] == 'W'){
y--;
}
land[x][y] = false;
}
S1 = vector<int>(C);
S1[0] = 0;
for (int i = 0; i < C - 1; i++){
S1[i + 1] = S1[i];
if (!land[0][i] && land[0][i + 1]){
S1[i + 1]++;
}
}
S2 = vector<int>(C);
S2[0] = 0;
for (int i = 0; i < C - 1; i++){
S2[i + 1] = S2[i];
if (!land[1][i] && land[1][i + 1]){
S2[i + 1]++;
}
}
S12 = vector<int>(C);
S12[0] = 0;
for (int i = 0; i < C - 1; i++){
S12[i + 1] = S12[i];
if (!land[0][i] && !land[1][i] && (land[0][i + 1] || land[1][i + 1])){
S12[i + 1]++;
}
if (land[0][i] && !land[1][i] && !land[0][i + 1] && land[1][i + 1]){
S12[i + 1]++;
}
if (!land[0][i] && land[1][i] && land[0][i + 1] && !land[1][i + 1]){
S12[i + 1]++;
}
}
}
int colour(int ar, int ac, int br, int bc){
ar--;
ac--;
if (ar == 0 && br == 1){
int ans = S1[bc - 1] - S1[ac];
if (land[0][ac]){
ans++;
}
return ans;
} else if (ar == 1 && br == 2){
int ans = S2[bc - 1] - S2[ac];
if (land[1][ac]){
ans++;
}
return ans;
} else {
int ans = S12[bc - 1] - S12[ac];
if (land[0][ac] || land[1][ac]){
ans++;
}
return ans;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
56 ms |
6312 KB |
Output is correct |
4 |
Correct |
60 ms |
6288 KB |
Output is correct |
5 |
Correct |
57 ms |
6340 KB |
Output is correct |
6 |
Correct |
53 ms |
6288 KB |
Output is correct |
7 |
Correct |
50 ms |
6396 KB |
Output is correct |
8 |
Correct |
71 ms |
6352 KB |
Output is correct |
9 |
Correct |
58 ms |
6372 KB |
Output is correct |
10 |
Correct |
51 ms |
6264 KB |
Output is correct |
11 |
Correct |
55 ms |
6348 KB |
Output is correct |
12 |
Correct |
62 ms |
6232 KB |
Output is correct |
13 |
Correct |
47 ms |
6268 KB |
Output is correct |
14 |
Correct |
48 ms |
6224 KB |
Output is correct |
15 |
Correct |
65 ms |
6328 KB |
Output is correct |
16 |
Correct |
64 ms |
6340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Runtime error |
396 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |