Submission #400704

#TimeUsernameProblemLanguageResultExecution timeMemory
400704my99nLand of the Rainbow Gold (APIO17_rainbow)C++14
11 / 100
18 ms840 KiB
#include "rainbow.h" #include <bits/stdc++.h> using namespace std; int a[55][55], vis[55][55]; int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}; void ffill (int i, int j, int ar, int ac, int br, int bc) { if (a[i][j]) return; if (vis[i][j]) return; vis[i][j] = 1; // cerr << i << ' ' << j << endl; for (int d = 0; d < 4; d++) { int ni = i+dx[d], nj = j+dy[d]; if (ni < ar or ni > br or nj < ac or nj > bc) continue; if (vis[ni][nj]) continue; if (a[ni][nj]) continue; ffill(ni, nj, ar, ac, br, bc); } } void init(int R, int C, int sr, int sc, int M, char *S) { a[sr][sc] = 1; 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++; a[sr][sc] = 1; } // for (int i = 1; i <= R; i++) { // for (int j = 1; j <= C; j++) { // cerr << a[i][j] << ' '; // } cerr << endl; // } } int colour(int ar, int ac, int br, int bc) { int cnt = 0; memset(vis, 0, sizeof vis); for (int i = ar; i <= br; i++) { for (int j = ac; j <= bc; j++) { if (vis[i][j]) continue; if (a[i][j]) continue; ffill(i, j, ar, ac, br, bc); // cerr << "fill " << ' ' << i << ' ' << j << endl; cnt++; } } return cnt; }
#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...