#include "rainbow.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
int grid[3][MAXN];
int psum[MAXN][3];
int last[MAXN][3];
void init(int R, int C, int sr, int sc, int M, char *S)
{
int x = sr, y = sc;
grid[sr][sc] = -1;
grid[1][0] = -1;
grid[2][0] = -1;
for(int i = 0; i < M; i++)
{
x -= (S[i] == 'N');
x += (S[i] == 'S');
y -= (S[i] == 'W');
y += (S[i] == 'E');
// cerr << x << " " << y << " COBRA \n";
grid[x][y] = -1;
}
for(int i = 1; i <= C; i++)
{
if(grid[1][i] == -1 || (grid[1][i] == grid[1][i-1]))
{
psum[i][0] = psum[i-1][0];
if(grid[1][i] == -1) last[i][0] = i;
else last[i][0] = last[i-1][0];
}
else
{
// cerr << "PENIS GIGANTE\n";
psum[i][0] = psum[i-1][0] + 1;
last[i][0] = last[i-1][0];
}
if(grid[2][i] == -1 || (grid[2][i] == grid[2][i-1]))
{
psum[i][1] = psum[i-1][1];
if(grid[2][i] == -1) last[i][1] = i;
else last[i][1] = last[i-1][1];
}
else
{
psum[i][1] = psum[i-1][1] + 1;
last[i][1] = last[i-1][1];
}
if((grid[1][i] == -1 && grid[2][i] == -1) || (grid[1][i] == grid[1][i-1] && grid[1][i] != -1) || (grid[2][i] == grid[2][i-1] && grid[2][i] != -1))
{
psum[i][2] = psum[i-1][2];
if(grid[1][i] == -1 && grid[2][i] == -1) last[i][2] = i;
else last[i][2] = last[i-1][2];
}
else
{
psum[i][2] = psum[i-1][2] + 1;
last[i][2] = last[i-1][2];
}
// cerr << grid[1][i] << " " << psum[i][0] << " " << last[i][0] << "||\n";
}
}
int calc(int ini, int fim, int type)
{
return psum[fim][type] - psum[min(ini,last[ini][type])][type];
}
int colour(int ar, int ac, int br, int bc)
{
if(ar == br && ar == 1) return calc(ac,bc,0);
if(ar == br && ar == 2) return calc(ac,bc,1);
if(ar != br) return calc(ac,bc,2);
}
Compilation message
rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:83:1: warning: control reaches end of non-void function [-Wreturn-type]
83 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
34 ms |
7584 KB |
Output is correct |
4 |
Correct |
35 ms |
7768 KB |
Output is correct |
5 |
Correct |
36 ms |
7704 KB |
Output is correct |
6 |
Correct |
37 ms |
10568 KB |
Output is correct |
7 |
Correct |
37 ms |
10312 KB |
Output is correct |
8 |
Correct |
35 ms |
7496 KB |
Output is correct |
9 |
Correct |
34 ms |
7760 KB |
Output is correct |
10 |
Correct |
37 ms |
10188 KB |
Output is correct |
11 |
Correct |
36 ms |
7504 KB |
Output is correct |
12 |
Correct |
34 ms |
10320 KB |
Output is correct |
13 |
Correct |
33 ms |
7760 KB |
Output is correct |
14 |
Correct |
34 ms |
7752 KB |
Output is correct |
15 |
Correct |
33 ms |
7504 KB |
Output is correct |
16 |
Correct |
37 ms |
7504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Runtime error |
3 ms |
592 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |