Submission #900121

#TimeUsernameProblemLanguageResultExecution timeMemory
900121Lincito_31Land of the Rainbow Gold (APIO17_rainbow)C++14
0 / 100
469 ms1048576 KiB
#include "rainbow.h" #include<bits/stdc++.h> using namespace std; vector<vector<char>> grid; void llenar(vector<vector<char>> &clon,int ar,int ac,int br,int bc,int i,int j){ clon[i][j]='x'; if(i==ar){ if(clon[i+1][j]==' '){ llenar(clon,ar,ac,br,bc,i+1,j); } if(j==ac){ if(clon[i][j+1]==' '){ llenar(clon,ar,ac,br,bc,i,j+1); } }else if(j==bc){ if(clon[i][j-1]==' '){ llenar(clon,ar,ac,br,bc,i,j-1); } }else{ if(clon[i][j+1]==' '){ llenar(clon,ar,ac,br,bc,i,j+1); } if(clon[i][j-1]==' '){ llenar(clon,ar,ac,br,bc,i,j-1); } } }else if(i==br){ if(clon[i-1][j]==' '){ llenar(clon,ar,ac,br,bc,i-1,j); } if(j==ac){ if(clon[i][j+1]==' '){ llenar(clon,ar,ac,br,bc,i,j+1); } }else if(j==bc){ if(clon[i][j-1]==' '){ llenar(clon,ar,ac,br,bc,i,j-1); } }else{ if(clon[i][j+1]==' '){ llenar(clon,ar,ac,br,bc,i,j+1); } if(clon[i][j-1]==' '){ llenar(clon,ar,ac,br,bc,i,j-1); } } }else{ if(clon[i+1][j]==' '){ llenar(clon,ar,ac,br,bc,i+1,j); } if(clon[i-1][j]==' '){ llenar(clon,ar,ac,br,bc,i-1,j); } if(j==ac){ if(clon[i][j+1]==' '){ llenar(clon,ar,ac,br,bc,i,j+1); } }else if(j==bc){ if(clon[i][j-1]==' '){ llenar(clon,ar,ac,br,bc,i,j-1); } }else{ if(clon[i][j+1]==' '){ llenar(clon,ar,ac,br,bc,i,j+1); } if(clon[i][j-1]==' '){ llenar(clon,ar,ac,br,bc,i,j-1); } } } } void init(int R, int C, int sr, int sc, int M, char *S) { vector<char> auxi(C,' '); for(int i=0;i<R;i++){ grid.push_back(auxi); } sr--; sc--; grid[sr][sc]='x'; for(int i=0;i<M;i++){ switch(S[i]){ case 'N': sr--; break; case 'S': sr++; break; case 'W': sc--; break; case 'E': sc++; break; } grid[sr][sc]='x'; } } int colour(int ar, int ac, int br, int bc) { int canti=0; ar--; ac--; br--; bc--; vector<vector<char>> clon(grid.begin(),grid.end()); for(int i=ar;i<=br;i++){ for(int j=ac;j<=bc;j++){ if(clon[i][j]==' '){ canti++; llenar(clon,ar,ac,br,bc,i,j); } } } return canti; }
#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...