Submission #569461

#TimeUsernameProblemLanguageResultExecution timeMemory
569461saarang123Land of the Rainbow Gold (APIO17_rainbow)C++17
0 / 100
1 ms344 KiB
#include "rainbow.h" #include <bits/stdc++.h> using namespace std; const int MXN = 200 * 1000 + 3; const vector<array<int, 2>> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; bool f[2][MXN]; int cnt[MXN]; int n, m; int con(int i, int j) { return m * i + j; } void init(int R, int C, int sr, int sc, int M, char *S) { n = R, m = C; int x = sr - 1, y = sc - 1; for(int i = 0; i < M; i++) { char c = S[i]; if(c == 'N') x--; else if(c == 'S') x++; else if(c == 'W') y--; else y++; f[x][y] = true; } bool last = true; for(int i = 0; i < m; i++) { if(f[0][i] && f[1][i]) { last = true; continue; } if(last) cnt[i]++, last = 0; if(i) cnt[i] += cnt[i - 1]; } } int colour(int ar, int ac, int br, int bc) { ar--, ac--, br--, bc--; return cnt[bc] - (ac ? cnt[ac - 1] : 0); } #ifdef saarang static int R, C, M, Q; static int sr, sc; static char S[100000 + 5]; int main() { scanf("%d %d %d %d", &R, &C, &M, &Q); scanf("%d %d", &sr, &sc); if (M > 0) { scanf(" %s ", S); } init(R, C, sr, sc, M, S); int query; for (query = 0; query < Q; query++) { int ar, ac, br, bc; scanf("%d %d %d %d", &ar, &ac, &br, &bc); printf("%d\n", colour(ar, ac, br, bc)); } return 0; } #endif
#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...