Submission #1276350

#TimeUsernameProblemLanguageResultExecution timeMemory
1276350LucaLucaM무지개나라 (APIO17_rainbow)C++20
0 / 100
11 ms572 KiB
#include "rainbow.h" #include <iostream> #include <vector> #include <cassert> #include <algorithm> #include <set> std::set<std::pair<int, int>> cells; void init(int R, int C, int sr, int sc, int M, char *S) { int x = sr, y = sc; cells.insert({x, y}); for (int i = 0; i < M; i++) { if (S[i] == 'N') { x--; } else if (S[i] == 'S') { x++; } else if (S[i] == 'W') { y--; } else { y++; } cells.insert({x, y}); } } int colour(int x1, int y1, int x2, int y2) { int V = 0; for (int i = x1; i <= x2; i++) { for (int j = y1; j <= y2; j++) { if (cells.count({i, j})) { V++; } } } int E = 0; for (int i = x1; i <= x2; i++) { for (int j = y1; j < y2; j++) { if (!cells.count({i, j}) && !cells.count({i, j + 1})) { E++; } } } for (int i = x1; i < x2; i++) { for (int j = y1; j <= y2; j++) { if (!cells.count({i, j}) && !cells.count({i + 1, j})) { E++; } } } int F = 0; for (int i = x1; i < x2; i++) { for (int j = y1; j < y2; j++) { if (!cells.count({i, j}) && !cells.count({i, j + 1}) && !cells.count({i + 1, j}) && !cells.count({i + 1, j + 1})) { F++; } } } F++; // std::cout << V << ' ' << E << ' ' << F << '\n'; // V + F = E + C + 1 (cred) return V + F - E - 1; }
#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...