Submission #923947

#TimeUsernameProblemLanguageResultExecution timeMemory
923947irmuunLand of the Rainbow Gold (APIO17_rainbow)C++17
11 / 100
3036 ms2376 KiB
#include<bits/stdc++.h> #include "rainbow.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() bool used[51][51],water[51][51]; vector<int>dx={1,-1,0,0}; vector<int>dy={0,0,1,-1}; int r1,r2,c1,c2; bool check(int x,int y){ if(x<r1||x>r2||y<c1||y>c2) return false; return true; } void dfs(int x,int y){ if(!check(x,y)||water[x][y]==true||used[x][y]==true) return; used[x][y]=true; for(int i=0;i<4;i++){ dfs(x+dx[i],y+dy[i]); } } void init(int R,int C,int sr,int sc,int M,char *S){ water[sr][sc]=true; for(int i=0;i<M;i++){ if(S[i]=='N') sr--; if(S[i]=='S') sr++; if(S[i]=='W') sc--; if(S[i]=='E') sc++; water[sr][sc]=true; } } int colour(int ar,int ac,int br,int bc){ r1=ar; r2=br; c1=ac; c2=bc; memset(used,0,sizeof used); int ans=0; for(int i=ar;i<=br;i++){ for(int j=ac;j<=bc;j++){ if(!used[i][j]&&water[i][j]==false){ ans++; dfs(i,j); } } } return ans; }
#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...