Submission #632490

#TimeUsernameProblemLanguageResultExecution timeMemory
632490mansurLand of the Rainbow Gold (APIO17_rainbow)C++17
11 / 100
3048 ms9660 KiB
#include "rainbow.h" #include<bits/stdc++.h> using namespace std; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define sz(a) a.size() #define pb push_back #define vt vector #define s second #define f first #define nl '\n' using ll = long long; using pii = pair<int, int>; vt<pii> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; const int N = 1e3 + 5, mod = 1e9 + 7; const int inf = 2e9; double eps = 1e-6; bool is[N][N], was[N][N]; int r, c; int ar, br, ac, bc; void init(int R, int C, int sr, int sc, int m, char *s) { is[sr][sc] = 1; r = R; c = C; 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++; is[sr][sc] = 1; } } bool ok(int x, int y) { return x >= ar && x <= br && y >= ac && y <= bc; } void dfs(int x, int y) { was[x][y] = 1; for (auto v: dir) { x += v.f; y += v.s; if (ok(x, y) && !is[x][y] && !was[x][y]) { dfs(x, y); } x -= v.f; y -= v.s; } } int colour(int aR, int aC, int bR, int bC) { ar = aR, ac = aC; br = bR, bc = bC; int cnt = 0; for (int i = ar; i <= br; i++) { for (int j = ac; j <= bc; j++) { if (!is[i][j] && !was[i][j]) { dfs(i, j); cnt++; } } } for (int i = ar; i <= br; i++) { for (int j = ac; j <= bc; j++) was[i][j] = 0; } 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...