#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include "rainbow.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e2+50;
const int mod=1e9+7;
using namespace std;
int h,w,tmp[nmax][nmax],viz[nmax][nmax],m,i,j,lx,ly,ux,uy,k;
void init(int R,int C,int sx,int sy,int M,char *s)
{
h=R,w=C,m=M;
for(i=0;i<=m;i++)
{
viz[sx][sy]=1;
if(i==m)break;
if(s[i]=='S')sx--;
else if(s[i]=='N')sx++;
else if(s[i]=='E')sy++;
else if(s[i]=='W')sy--;
}
}
bool ok(int x,int y)
{
if(x<lx || x>ux || y<ly || y>uy || tmp[x][y])return 0;
return 1;
}
void dfs(int x,int y)
{
if(!ok(x,y))return;
tmp[x][y]=1;
//for(int i=-1;i<=1;i++)for(int j=-1;j<=1;j++)if(i || j)dfs(x+i,y+j);
dfs(x+1,y);
dfs(x-1,y);
dfs(x,y+1);
dfs(x,y-1);
}
int colour(int Lx,int Ly,int Ux,int Uy)
{
lx=Lx,ly=Ly,ux=Ux,uy=Uy;
for(i=1;i<=h;i++)for(j=1;j<=w;j++)tmp[i][j]=viz[i][j];
k=0;
for(i=lx;i<=ux;i++)
{
for(j=ly;j<=uy;j++)
{
if(tmp[i][j])continue;
dfs(i,j);
k++;
}
}
return k;
}
/*int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
init(6,4,3,3,9,"NWESSWEWS");
cout<<colour(2,3,2,3)<<endl;
cout<<colour(3,2,4,4)<<endl;
cout<<colour(5,3,6,4)<<endl;
cout<<colour(1,2,5,3)<<endl;
return 0;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Runtime error |
5 ms |
760 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |