Submission #1117111

#TimeUsernameProblemLanguageResultExecution timeMemory
1117111SofiatpcLand of the Rainbow Gold (APIO17_rainbow)C++14
11 / 100
10 ms592 KiB
#include <bits/stdc++.h> #include "rainbow.h" using namespace std; int marc[55][55], n1, n2,m1,m2; int di[4] = {0,0,-1,1}; int dj[4] = {-1,1,0,0}; void init(int R, int C, int sr, int sc, int m, char *s) { marc[sr][sc] = 2; for(int i = 0; i < m; i++){ if(s[i] == 'N')sr--; else if(s[i] == 'S')sr++; else if(s[i] == 'W')sc--; else sc++; marc[sr][sc] = 2; } } void dfs(int i, int j){ marc[i][j] = 1; for(int d = 0; d < 4; d++){ int ni = i + di[d], nj = j + dj[d]; if(ni < n1 || ni > n2 || nj < m1 || nj > m2 || marc[ni][nj])continue; dfs(ni,nj); } } int colour(int ar, int ac, int br, int bc) { for(int i = ar; i <= br; i++) for(int j = ac; j <= bc; j++) if(marc[i][j] != 2)marc[i][j] = 0; n1 = ar; n2 = br; m1 = ac; m2 = bc; int qtd = 0; for(int i = ar; i <= br; i++) for(int j = ac; j <= bc; j++) if(marc[i][j] == 0){ qtd++; dfs(i,j); } return qtd; }
#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...