#include "bits/stdc++.h"
#include "rainbow.h"
// #include "grader.cpp"
using namespace std;
const int N = 1e2 + 5;
const int N1 = 2e5 + 5;
int a[N][N1], vis[N][N], n, m, n1, n2, m1, m2, p[4][N1];
void init(int r, int c, int sr, int sc, int M, char *s) {
a[sr][sc] = true;
n = r, m = c;
for(int i = 0; i < M; i++) {
if(s[i] == 'N') sr--;
if(s[i] == 'S') sr++;
if(s[i] == 'W') sc--;
if(s[i] == 'E') sc++;
a[sr][sc] = true;
}
a[1][0] = a[2][0] = true;
bool t1 = 0, t2 = 0;
for(int i = 1; i <= m; i++) {
t1 = a[1][i-1], t2 = a[2][i-1];
p[1][i] = p[1][i-1] + (t1 and !a[1][i]);
p[2][i] = p[2][i-1] + (t2 and !a[2][i]);
p[3][i] = p[3][i-1] + (t1 and t2 and (!a[1][i] or !a[2][i]));
}
}
int colour(int ar, int ac, int br, int bc) {
memset(vis, 0, sizeof vis);
if(br == ar) return (p[ar][bc] - p[br][ac-1] + (a[ar][ac] == 0 and a[ar][ac-1] == 0));
return (p[3][bc] - p[3][ac-1] + (a[1][ac-1] + a[2][ac-1] != 2 and a[1][ac] + a[2][ac] != 2));
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |