Submission #262893

#TimeUsernameProblemLanguageResultExecution timeMemory
262893srvlt무지개나라 (APIO17_rainbow)C++14
0 / 100
4 ms3840 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define all(x) begin(x), end(x) #define SZ(x) (int)(x).size() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #include "rainbow.h" const int n0 = 2e5 + 123; int n, r, c, a[3][n0], s[3][n0], num[3][n0]; void init(int R, int C, int sr, int sc, int M, char *S) { r = R, c = C; for (int i = 1; i <= r; i++) for (int j = 1; j <= c; j++) a[i][j] = 1; int x = sr, y = sc; a[x][y] = 0; for (int i = 0; i < M; i++) { if (S[i] == 'N') x--; if (S[i] == 'S') x++; if (S[i] == 'W') y--; if (S[i] == 'E') y++; a[x][y] = 0; } for (int i = 1; i < r; i++) { for (int j = 1; j < c; j++) { if ((a[i][j] && a[i + 1][j]) || (a[i][j + 1] && a[i + 1][j + 1])) s[i][j] = 1; s[i][j] += s[i][j - 1]; } } for (int i = 1; i <= r; i++) for (int j = 1; j <= c; j++) num[i][j] = num[i][j - 1] + a[i][j]; } int colour(int ar, int ac, int br, int bc) { int res = 0; for (int x = ar; x <= br; x++) { if (num[x][bc] - num[x][ac - 1] == 0) continue; if (x == ar || s[x - 1][bc - 1] - s[x - 1][ac - 1] == 0) res++; } return res; }
#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...