제출 #262834

#제출 시각아이디문제언어결과실행 시간메모리
262834srvlt무지개나라 (APIO17_rainbow)C++14
11 / 100
105 ms4088 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 = 53; int n, r, c, bad[n0][n0], used[n0][n0]; int dx[] = {-1, 0, 0, 1}; int dy[] = {0, -1, 1, 0}; void dfs(int x, int y) { if (x < 1 || x > r || y < 1 || y > c || bad[x][y] || used[x][y]) return; used[x][y] = 1; for (int i = 0; i < 4; i++) dfs(x + dx[i], y + dy[i]); } void init(int R, int C, int sr, int sc, int M, char *S) { r = R, c = C; int x = sr, y = sc; bad[x][y] = 1; 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++; bad[x][y] = 1; } } int colour(int ar, int ac, int br, int bc) { for (int i = 1; i <= r; i++) for (int j = 1; j <= c; j++) if (i < ar || i > br || j < ac || j > bc) bad[i][j]++; int res = 0; memset(& used, 0, sizeof(used)); for (int i = 1; i <= r; i++) for (int j = 1; j <= c; j++) if (!used[i][j] && !bad[i][j]) dfs(i, j), res++; for (int i = 1; i <= r; i++) for (int j = 1; j <= c; j++) if (i < ar || i > br || j < ac || j > bc) bad[i][j]--; 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...