Submission #252958

#TimeUsernameProblemLanguageResultExecution timeMemory
252958orgioooLand of the Rainbow Gold (APIO17_rainbow)C++14
0 / 100
3078 ms640 KiB
#include <bits/stdc++.h> #include <rainbow.h> #define ll long long #define pb push_back #define ret return 0 #define con continue #define db double #define gcd __gcd #define freopen freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); using namespace std; ll n,m,ans,t,cnt,x,y,z,u; ll i,j,r,l,k; ll a[123],b[123],d[123],e[123]; map <ll,ll> f; set<pair<ll,ll>> s; set<int>::iterator it; vector <ll> c[123]; string p[200],q,w[200]; ll lcm(ll x,ll y){ ll z=gcd(x,y); return x*y/z; } void init(int R, int C, int sr, int sc, int M, char *S) { n=R;m=C;x=sr;y=sc;k=M; x--;y--; for(i=0;i<n;i++){ for(j=0;j<m;j++){ w[i][j]='0'; } } w[x][y]='1'; for(i=0;i<k;i++){ if (S[i]=='W'){ y--; } if (S[i]=='E'){ y++; } if (S[i]=='N'){ x--; } if (S[i]=='S'){ x++; } w[x][y]='1'; } return; } int colour(int ar, int ac, int br, int bc) { ll x1 = ar; ll y1 = ac; ll x2 = br; ll y2 = bc; x1--;y1--;x2--;y2--; for(i=x1;i<=x2;i++){ for(j=y1;j<=y2;j++){ p[i-x1][j-y1]=w[i][j]; } } x=x2-x1;y=y2-y1;x++;y++; cnt=0 ; for (i=0;i<x;i++){ for(j=0;j<y;j++){ if (p[i][j]=='0'){ cnt ++ ; } } } l=1; while (cnt>0){ ll ss =0 ; for (i=0;i<x;i++){ for(j=0;j<y;j++){ if (p[i][j]>49){ if (i+1<x&&p[i+1][j]=='0'){ ss++; p[i+1][j]=p[i][j]; } if (j+1<y&&p[i][j+1]=='0'){ ss++; p[i][j+1]=p[i][j]; } if (i-1>=0&&p[i-1][j]=='0'){ ss++; p[i-1][j]=p[i][j]; } if (j-1>=0&&p[i][j-1]=='0'){ ss++; p[i][j-1]=p[i][j]; } } } } if (ss==0){ l++; for (i=0;i<x;i++){ ll kk =0; for(j=0;j<y;j++){ if (p[i][j]=='0'){ p[i][j]=char(l+48); kk++;break; } } if (kk>0){ break; } } } cnt=0; for (i=0;i<x;i++){ for(j=0;j<y;j++){ if (p[i][j]=='0'){ cnt ++ ; } } } } return l-2+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...