#include "rainbow.h"
#include <bits/stdc++.h>
int a[200005][1000],h=1,b[200005][1000],o=0,r,c;
void init(int R, int C, int sr, int sc, int m, char *s)
{
r=R;
c=C;
a[sr][sc]=1;
int x=sr,y=sc;
b[x][y]=-1;
for (int i=0;i<m;i++)
{
if (*s=='W')x--;
else if (*s=='E')x++;
else if (*s=='N')y--;
else y++;
a[x][y]=1;
b[x][y]=-1;
s++;
}
}
void vis(int i,int j,int ar, int ac, int br, int bc)
{
b[i][j]=h;
if (b[max(i-1,0)][j]!=h&&b[max(i-1,0)][j]!=-1&&i>0&&i-1>=ac)vis(i-1,j,ar,ac,br,bc);
if (b[i][max(j-1,0)]!=h&&b[i][max(j-1,0)]!=-1&&j>0&&j-1>=ar)vis(i,j-1,ar,ac,br,bc);
if (b[i+1][j]!=h&&b[i+1][j]!=-1&&i<=c-1&&i+1<=bc)vis(i+1,j,ar,ac,br,bc);
if (b[i][j+1]!=h&&b[i][j+1]!=-1&&j<=r-1&&j+1<=br)vis(i,j+1,ar,ac,br,bc);
}
int f(int i,int j,int ar, int ac, int br, int bc)
{
if (b[i][j]==h||b[i][j]==-1)
{
return 0;
}
vis(i,j,ar,ac,br,bc);
return 1;
}
int colour(int ar, int ac, int br, int bc)
{
o=0;
for (int i=ac;i<=bc;i++)
{
for (int j=ar;j<=br;j++)
{
o+=f(i,j,ar,ac,br,bc);
}
}
h++;
return o;
}
Compilation message
rainbow.cpp: In function 'void vis(int, int, int, int, int, int)':
rainbow.cpp:25:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
25 | if (b[max(i-1,0)][j]!=h&&b[max(i-1,0)][j]!=-1&&i>0&&i-1>=ac)vis(i-1,j,ar,ac,br,bc);
| ^~~
| std::max
In file included from /usr/include/c++/10/algorithm:62,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
from rainbow.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
3486 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
rainbow.cpp:26:14: error: 'max' was not declared in this scope; did you mean 'std::max'?
26 | if (b[i][max(j-1,0)]!=h&&b[i][max(j-1,0)]!=-1&&j>0&&j-1>=ar)vis(i,j-1,ar,ac,br,bc);
| ^~~
| std::max
In file included from /usr/include/c++/10/algorithm:62,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
from rainbow.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
3486 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~