Submission #945100

#TimeUsernameProblemLanguageResultExecution timeMemory
945100TAhmed33무지개나라 (APIO17_rainbow)C++98
11 / 100
10 ms860 KiB
#include "rainbow.h" #include <bits/stdc++.h> using namespace std; bool ok[51][51]; bool vis[51][51]; int dx[4] = {0, -1, 0, 1}, dy[4] = {1, 0, -1, 0}; map <char, int> lk = { {'E', 0}, {'N', 1}, {'W', 2}, {'S', 3} }; int n, m; void init (int N, int M, int x, int y, int z, char *s) { n = N; m = M; x--; y--; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) ok[i][j] = 1; ok[x][y] = 0; for (int i = 0; i < z; i++) { x += dx[lk[s[i]]]; y += dy[lk[s[i]]]; ok[x][y] = 0; } } void dfs (int x, int y, int a, int b, int c, int d) { vis[x][y] = 1; for (int i = 0; i < 4; i++) { int g = x + dx[i], h = y + dy[i]; if (g >= a && g <= b && h >= c && h <= d && ok[g][h] && !vis[g][h]) { dfs(g, h, a, b, c, d); } } } int colour (int ar, int br, int ac, int bc) { ar--; br--; ac--; bc--; for (int i = ar; i <= ac; i++) { for (int j = br; j <= bc; j++) { vis[i][j] = 0; } } if (ar > ac) swap(ar, ac); if (br > bc) swap(br, bc); int ret = 0; for (int i = ar; i <= ac; i++) { for (int j = br; j <= bc; j++) { if (!ok[i][j]) continue; if (!vis[i][j]) { dfs(i, j, ar, ac, br, bc); ret++; } } } return ret; }
#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...