Submission #227320

#TimeUsernameProblemLanguageResultExecution timeMemory
227320abekerChecker (COCI19_checker)C++17
110 / 110
1071 ms76000 KiB
#include <bits/stdc++.h> using namespace std; typedef pair <int, int> pii; const int MAXN = 2e5 + 5; int N; char sides[MAXN]; vector <pii> adj[MAXN]; map <pii, int> clr; void add_edge(int a, int b, int c) { adj[a].push_back({b, c}); adj[b].push_back({a, c}); clr[{a, b}] = clr[{b, a}] = c; } void load() { scanf("%*d%d%s", &N, sides); for (int i = 0; i < N; i++) add_edge(i, (i + 1) % N, sides[i] - '0'); for (int i = 0; i < N - 3; i++) { int x, y, c; scanf("%d%d%d", &x, &y, &c); add_edge(--x, --y, c); } } void solve() { bool coloring = true; for (int i = 0; i < N; i++) { sort(adj[i].begin(), adj[i].end()); auto it = lower_bound(adj[i].begin(), adj[i].end(), pii(i, 0)); if (it == adj[i].end()) it = adj[i].begin(); rotate(adj[i].begin(), it, adj[i].end()); for (int j = 1; j < adj[i].size(); j++) { pii x = adj[i][j - 1], y = adj[i][j]; int tmp = clr[{x.first, y.first}]; if (!tmp) { puts("neispravna triangulacija"); return; } coloring &= tmp != x.second && tmp != y.second && x.second != y.second; } } puts(coloring ? "tocno" : "neispravno bojenje"); } int main() { load(); solve(); return 0; }

Compilation message (stderr)

checker.cpp: In function 'void solve()':
checker.cpp:38:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 1; j < adj[i].size(); j++) {
                   ~~^~~~~~~~~~~~~~~
checker.cpp: In function 'void load()':
checker.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%*d%d%s", &N, sides);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
checker.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &x, &y, &c);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...