#include<bits/stdc++.h>
using namespace std;
vector< vector<bool> >matriz;
void init(int R,int C,int sr, int sc, int M, string S){
for(int i=0;i<R;i++){
vector<bool> fil(C,false);
matriz.push_back(fil);
}
sr--;
sc--;
matriz[sr][sc]=1;
for(int i=0;i<M;i++){
int dir=S[i];
if(dir=='N')sr--;
if(dir=='W')sc--;
if(dir=='S')sr++;
if(dir=='E')sc++;
if(sr>=0 && sr<R && sc>=0 && sc<C) matriz[sr][sc]=1;
else{
if(sr<0)sr=0;
if(sr>=R)sr=R-1;
if(sc<0)sc=0;
if(sc>=C)sc=C-1;
}
}
}
int colours(int ar,int ac,int br,int bc){
ar--;
ac--;
br--;
bc--;
int c=0;
bool sc=false;
for(int i=ar;i<=br;i++){
for(int j=ac;j<=bc;j++){
// cout<<i<<" "<<j<<endl;
if(matriz[i][j]==0 && sc==false){
c++;
sc=true;
}
else{
if(matriz[i][j]==1){
if(ar!=br){
if(i==0){
if(matriz[i+1][j]==1)sc=false;
}
}
else sc=false;
}
}
}
}
return c;
}
/*int main(){
int R,C,M,Q,sr,sc,ar,ac,br,bc;
string S;
cin>>R>>C>>M>>Q;
cin>>sr>>sc;
cin>>S;
init(R,C,sr,sc,M,S);
for(int i=0;i<Q;i++){
cin>>ar>>ac>>br>>bc;
int ans=colours(ar,ac,br,bc);
cout<<ans<<"\n";
}
return 0;
}*/
Compilation message
/usr/bin/ld: /tmp/ccbKHH7n.o: in function `main':
grader.cpp:(.text.startup+0xed): undefined reference to `init(int, int, int, int, int, char*)'
/usr/bin/ld: grader.cpp:(.text.startup+0x167): undefined reference to `colour(int, int, int, int)'
collect2: error: ld returned 1 exit status