#include "rainbow.h"
#include <queue>
using namespace std;
const int N = 200005;
int color[3][N];
int st[N];
int st1[N];
int st2[N];
void init(int R, int C, int sr, int sc, int M, char *S) {
color[sr][sc] = 1;
for (int i = 0; i < M; i++)
{
if (S[i] == 'W')
{
sc--;
}
if (S[i] == 'S')
{
sr++;
}
if (S[i] == 'E')
{
sc++;
}
if (S[i] == 'N')
{
sr--;
}
color[sr][sc] = 1;
}
if(color[1][1] == 0 || color[2][1] == 0)
st[1] = 1;
for (int i = 2; i <= C; i++)
{
if ((color[1][i] == 0 && color[1][i - 1] == 0) || (color[2][i] == 0 && color[2][i - 1] == 0))
st[i] = st[i - 1];
else
{
if (color[1][i] == 0 || color[2][i] == 0)
st[i] = st[i + 1];
else
st[i] = st[i - 1];
}
}
if (color[1][1] == 0)
st1[1] = 1;
for (int i = 2; i <= C; i++)
{
if (color[1][i] == 1)
st1[i] = st1[i - 1];
else if (color[1][i - 1] == 0)
st1[i] = st1[i - 1];
else
st1[i] = st1[i - 1] + 1;
}
if (color[2][1] == 0)
st2[1] = 1;
for (int i = 2; i <= C; i++)
{
if (color[2][i] == 1)
st2[i] = st2[i - 1];
else if (color[2][i - 1] == 0)
st2[i] = st2[i - 1];
else
st2[i] = st2[i - 1] + 1;
}
}
int colour(int ar, int ac, int br, int bc) {
int qan = 0;
if (ar == 1 && br == 1)
{
if (color[1][ac] == color[1][ac - 1] && color[1][ac] == 0)
{
qan = st1[bc] - st1[ac - 1] + 1;
}
else
{
qan = st1[bc] - st1[ac - 1];
}
}
else if (ar == 2 && br == 2)
{
if (color[2][ac] == color[2][ac - 1] && color[2][ac] == 0)
{
qan = st2[bc] - st2[ac - 1] + 1;
}
else
{
qan = st2[bc] - st2[ac - 1];
}
}
else
{
if ((color[1][ac] == 0 && color[1][ac - 1] == 0) || (color[2][ac] == 0 && color[2][ac - 1] == 0))
{
qan = st2[bc] - st2[ac - 1] + 1;
}
else
{
qan = st2[bc] - st2[ac - 1];
}
}
return qan;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 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 |
- |