#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
int dr[] = {-1, 0, 1, 0};
int dc[] = {0, 1, 0, -1};
int R, C;
bitset<MAX> land[MAX];
int sum[3][MAXN];
// int color[3][MAXN], _color = 0;
// void dfs_1(int r, int c, int ar, int ac, int br, int bc) {
// for (int d = 0; d < 4; d++) {
// int nr = r + dr[d], nc = c + dc[d];
// if (r >= ar && r <= br && c >= ac && c <= bc && land[nr][nc] && color[nr][nc] == 0) {
// color[nr][nc] = color[r][c];
// dfs_1(nr, nc, ar, ac, br, bc);
// }
// }
// }
void init(int _R, int _C, int sr, int sc, int M, char *S) {
R = _R; C = _C;
for (int r = 1; r <= R; r++)
for (int c = 1; c <= C; c++)
land[r][c] = true;
land[sr][sc] = false;
for (int i = 0; i < M; i++) {
int d = 0;
switch(S[i]) {
case 'N': d = 0; break;
case 'E': d = 1; break;
case 'S': d = 2; break;
case 'W': d = 3; break;
}
sr += dr[d];
sc += dc[d];
land[sr][sc] = false;
}
for (int r = 1; r <= R; r++) {
for (int c = 1; c <= C; c++) {
if (land[r][c+1]) {
sum[r][c] = sum[r][c-1] + 1;
} else {
sum[r][c] = sum[r][c-1];
}
}
}
}
int colour(int ar, int ac, int br, int bc) {
int ret = 0;
for (int r = ar; r <= br; r++) {
ret += sum[r][bc] - sum[r][ac-1] + (land[r][bc] ? 0 : 1);
}
}
Compilation message
rainbow.cpp:11:8: error: 'MAX' was not declared in this scope
bitset<MAX> land[MAX];
^~~
rainbow.cpp:11:8: note: suggested alternative: 'MAXN'
bitset<MAX> land[MAX];
^~~
MAXN
rainbow.cpp:11:11: error: template argument 1 is invalid
bitset<MAX> land[MAX];
^
rainbow.cpp:11:18: error: 'MAX' was not declared in this scope
bitset<MAX> land[MAX];
^~~
rainbow.cpp:11:18: note: suggested alternative: 'MAXN'
bitset<MAX> land[MAX];
^~~
MAXN
rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:29:13: error: 'land' was not declared in this scope
land[r][c] = true;
^~~~
rainbow.cpp:29:13: note: suggested alternative: 'rand'
land[r][c] = true;
^~~~
rand
rainbow.cpp:31:5: error: 'land' was not declared in this scope
land[sr][sc] = false;
^~~~
rainbow.cpp:31:5: note: suggested alternative: 'rand'
land[sr][sc] = false;
^~~~
rand
rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:59:45: error: 'land' was not declared in this scope
ret += sum[r][bc] - sum[r][ac-1] + (land[r][bc] ? 0 : 1);
^~~~
rainbow.cpp:59:45: note: suggested alternative: 'rand'
ret += sum[r][bc] - sum[r][ac-1] + (land[r][bc] ? 0 : 1);
^~~~
rand
rainbow.cpp:61:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^