#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[2][i] == 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 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Runtime error |
2 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 |
- |