Submission #222467

#TimeUsernameProblemLanguageResultExecution timeMemory
222467shenxyChecker (COCI19_checker)C++11
110 / 110
927 ms37856 KiB
#include <cstdio> #include <algorithm> #include <map> #include <set> using namespace std; typedef pair<int, int> ii; typedef pair<int, ii> iii; int main() { int N; scanf("%d", &N); scanf("%d", &N); map<ii, char> edges; char edge; for (int i = 0; i < N; ++i) { scanf(" %c", &edge); edges[ii(min(i, (i + 1) % N), max(i, (i + 1) % N))] = edge; } int X, Y; set<int> rempts; set<iii> vulpts; for (int i = 0; i < N; ++i) rempts.insert(i); for (int i = 0; i < N - 3; ++i) { scanf("%d %d %c", &X, &Y, &edge); edges[ii(min(X - 1, Y - 1), max(X - 1, Y - 1))] = edge; if (min(X, Y) == 1 && max(X, Y) == N - 1) vulpts.insert(iii(N - 1, ii(N - 2, 0))); else if (min(X, Y) == 2 && max(X, Y) == N) vulpts.insert(iii(0, ii(N - 1, 1))); else if (max(X, Y) - min(X, Y) == 2) vulpts.insert(iii(min(X, Y), ii(min(X, Y) - 1, max(X, Y) - 1))); } bool patriot = true; for (int i = 0; i < N - 2; ++i) { if (vulpts.empty()) { printf("neispravna triangulacija"); return 0; } iii vr = *vulpts.begin(); int a = vr.first, b = *(rempts.find(a) == rempts.begin() ? --rempts.end() : --rempts.find(a)), c = *(rempts.find(a) == --rempts.end() ? rempts.begin() : ++rempts.find(a)); if (b != vr.second.first || c != vr.second.second) { printf("neispravna triangulacija"); return 0; } vulpts.erase(vr); rempts.erase(a); if (edges[ii(min(a, b), max(a, b))] == edges[ii(min(a, c), max(a, c))] || edges[ii(min(a, b), max(a, b))] == edges[ii(min(b, c), max(b, c))] || edges[ii(min(c, b), max(c, b))] == edges[ii(min(a, c), max(a, c))]) patriot = false; int d = *(rempts.find(b) == rempts.begin() ? --rempts.end() : --rempts.find(b)), e = *(rempts.find(c) == --rempts.end() ? rempts.begin() : ++rempts.find(c)); if (edges.find(ii(min(c, d), max(c, d))) != edges.end()) vulpts.insert(iii(b, ii(d, c))); if (edges.find(ii(min(b, e), max(b, e))) != edges.end()) vulpts.insert(iii(c, ii(b, e))); } if (patriot) printf("tocno"); else printf("neispravno bojenje" ); return 0; }

Compilation message (stderr)

checker.cpp: In function 'int main()':
checker.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
checker.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
checker.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c", &edge);
   ~~~~~^~~~~~~~~~~~~~
checker.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %c", &X, &Y, &edge);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...