#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][j-1] && grid[i][j]) pref[j][i]++;
}
FOR(j, 1, c) {
pref[j][0] = pref[j-1][0];
bool ok = false;
FOR(i, 1, r) if (grid[i][j]) ok = true;
FOR(i, 1, r) if (grid[i][j-1] && grid[i][j]) ok = false;
if (ok) pref[j][0] ++;
}
// FOR(i, 0, 2) FOR(j, 1, c) cout << " j = " << j << " i = " << i << " pref = " << pref[j][i] << endl;
}
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 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Runtime error |
11 ms |
11788 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 |
- |