Submission #208600

# Submission time Handle Problem Language Result Execution time Memory
208600 2020-03-11T18:21:38 Z MvC Land of the Rainbow Gold (APIO17_rainbow) C++11
11 / 100
29 ms 2040 KB
#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,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(int i=0;i<=m;i++)
	{
		viz[sx][sy]=1;
		if(i==m)break;
		if(s[i]=='N')sx--;
		else if(s[i]=='S')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;
	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;
	int i,j,k=0;
	for(i=1;i<=h;i++)for(j=1;j<=w;j++)tmp[i][j]=viz[i][j];
	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;
}*/
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 13 ms 504 KB Output is correct
3 Correct 29 ms 1400 KB Output is correct
4 Correct 27 ms 1144 KB Output is correct
5 Correct 16 ms 736 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 21 ms 1016 KB Output is correct
12 Correct 18 ms 888 KB Output is correct
13 Correct 14 ms 632 KB Output is correct
14 Correct 10 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Runtime error 7 ms 2040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Runtime error 6 ms 736 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 13 ms 504 KB Output is correct
3 Correct 29 ms 1400 KB Output is correct
4 Correct 27 ms 1144 KB Output is correct
5 Correct 16 ms 736 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 21 ms 1016 KB Output is correct
12 Correct 18 ms 888 KB Output is correct
13 Correct 14 ms 632 KB Output is correct
14 Correct 10 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Runtime error 6 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 13 ms 504 KB Output is correct
3 Correct 29 ms 1400 KB Output is correct
4 Correct 27 ms 1144 KB Output is correct
5 Correct 16 ms 736 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 21 ms 1016 KB Output is correct
12 Correct 18 ms 888 KB Output is correct
13 Correct 14 ms 632 KB Output is correct
14 Correct 10 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Runtime error 6 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -