#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
int id (int x, int y) {
return x * 1100 + y;
}
int par[1100*1100];
int find (int a) {return par[a] = par[a]==a ? a : find(par[a]);}
bool same (int a, int b) {return find(a) == find(b);}
void unite (int a, int b){
a = find(a), b = find(b);
if (a == b) return;
par[b] = a;
}
bool grid[5][200100];
int r, c;
int pref[200100][3];
void init(int R, int C, int sr, int sc, int M, char *S) {
r = R;
c = C;
int curX = sr, curY = sc;
FOR(i, 1, r) FOR(j, 1, c) grid[i][j] = true;
grid[curX][curY] = false;
FOR(i, 0, M-1) {
char c = S[i];
if (c == 'N') curX--;
else if (c == 'S') curX++;
else if (c == 'W') curY--;
else curY++;
grid[curX][curY] = false;
}
FOR(j, 1, c) FOR(i, 1, r) {
pref[j][i] = pref[j-1][i];
if (!grid[i-1][j] && grid[i][j]) pref[j][i]++;
}
FOR(j, 1, c) {
pref[j][0] = pref[j-1][0];
bool ok = true;
FOR(i, 1, r) if (grid[i][j-1] && grid[i][j]) ok = false;
if (ok) pref[j][0] ++;
}
}
int colour(int ar, int ac, int br, int bc) {
if (ar == br) return pref[bc][ar] - pref[ac-1][ar];
else return pref[bc][0] - pref[ac-1][0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
10 ms |
11632 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |