#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>r;
int n,m;
vector<int>dx = {-1,0,1,0};
vector<int>dy = {0,1,0,-1};
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R,m = c;
r.resize(R,vector<int>(C,0));
--sr;--sc;
for (auto x:*S){
r[sr][sc] = 1;
if (x == 'N'){
sr--;
}
else if (x == 'S'){
sr++;
}
else if (x == 'W'){
sc--;
}
else{
sc++;
}
}
}
int colour(int ar, int ac, int br, int bc) {
vector<vector<bool>>visited(n,vector<bool>(m,0));
int ans = 0;
function<void(int,int)>dfs = [&](int u,int v){
visited[u][v] = true;
for (int i = 0;i<4;++i){
int nx = u + dx[i];
int ny = v + dy[i];
if (nx >=ar - 1 && nx < br && ny >= ac - 1 && ny < bc && !visited[nx][ny]){
dfs(nx,ny);
}
}
};
for (int i = ar - 1;i<br;++i){
for (int j = ac - 1;j<bc;++j){
if (!visited[i][j]){
dfs(i,j);
ans++;
}
}
}
return ans;
}
Compilation message
rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:9:12: error: 'c' was not declared in this scope
9 | n = R,m = c;
| ^
rainbow.cpp:12:15: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
12 | for (auto x:*S){
| ^
| std::begin
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
from rainbow.cpp:2:
/usr/include/c++/10/valarray:1224:5: note: 'std::begin' declared here
1224 | begin(const valarray<_Tp>& __va)
| ^~~~~
rainbow.cpp:12:15: error: 'end' was not declared in this scope; did you mean 'std::end'?
12 | for (auto x:*S){
| ^
| std::end
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
from rainbow.cpp:2:
/usr/include/c++/10/valarray:1244:5: note: 'std::end' declared here
1244 | end(const valarray<_Tp>& __va)
| ^~~