Submission #416885

#TimeUsernameProblemLanguageResultExecution timeMemory
416885Aldas25Land of the Rainbow Gold (APIO17_rainbow)C++14
0 / 100
11 ms11788 KiB
#include "rainbow.h" #include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1, (n)) #define f first #define s second #define pb push_back typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vii; int id (int x, int y) { return x * 1100 + y; } int par[1100*1100]; int find (int a) {return par[a] = par[a]==a ? a : find(par[a]);} bool same (int a, int b) {return find(a) == find(b);} void unite (int a, int b){ a = find(a), b = find(b); if (a == b) return; par[b] = a; } bool grid[5][200100]; int r, c; int pref[200100][3]; void init(int R, int C, int sr, int sc, int M, char *S) { r = R; c = C; int curX = sr, curY = sc; FOR(i, 1, r) FOR(j, 1, c) grid[i][j] = true; grid[curX][curY] = false; FOR(i, 0, M-1) { char c = S[i]; if (c == 'N') curX--; else if (c == 'S') curX++; else if (c == 'W') curY--; else curY++; grid[curX][curY] = false; } FOR(j, 1, c) FOR(i, 1, r) { pref[j][i] = pref[j-1][i]; if (!grid[i][j-1] && grid[i][j]) pref[j][i]++; } FOR(j, 1, c) { pref[j][0] = pref[j-1][0]; bool ok = false; FOR(i, 1, r) if (grid[i][j]) ok = true; FOR(i, 1, r) if (grid[i][j-1] && grid[i][j]) ok = false; if (ok) pref[j][0] ++; } // FOR(i, 0, 2) FOR(j, 1, c) cout << " j = " << j << " i = " << i << " pref = " << pref[j][i] << endl; } int colour(int ar, int ac, int br, int bc) { if (ar == br) return pref[bc][ar] - pref[ac-1][ar]; else return pref[bc][0] - pref[ac-1][0]; }
#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...