#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[0][i] && !land[0][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 |
340 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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
448 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |