Submission #292314

#TimeUsernameProblemLanguageResultExecution timeMemory
292314kingfran1907Checker (COCI19_checker)C++14
110 / 110
238 ms10848 KiB
#include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long llint; const int maxn = 2e5+10; const int base = 31337; const int mod = 1e9+7; const int inf = 0x3f3f3f3f; const int logo = 20; const int off = 1 << logo; const int treesiz = off << 1; int t; int n; int c[maxn]; vector< pair< pair<int, int>, int > > v; bool bio[maxn]; int nx[maxn]; bool cmp(pair< pair<int, int>, int> a, pair< pair<int, int>, int> b) { return ((a.X.Y - a.X.X + n) % n) < ((b.X.Y - b.X.X + n) % n); } int main() { scanf("%d%d", &t, &n); memset(bio, false, sizeof bio); for (int i = 0; i < n; i++) { char x; scanf(" %c", &x); c[i] = x - '1'; nx[i] = (i + 1) % n; } for (int i = 3; i < n; i++) { int a, b, c; scanf("%d%d%d", &a, &b, &c); a--, b--, c--; v.push_back(make_pair(make_pair(a, b), c)); v.push_back(make_pair(make_pair(b, a), c)); } sort(v.begin(), v.end(), cmp); bool flag1 = true; bool flag2 = true; for (int i = 0; i < n - 3; i++) { int x = v[i].X.X; int y = v[i].X.Y; int cl = v[i].Y; //printf("debug: %d %d -> %d %d %d\n", x + 1, y + 1, c[x], c[nx[x]], cl); if (bio[x] || bio[y]) { flag1 = false; break; } if (nx[nx[x]] != y) { flag1 = false; break; } bio[nx[x]] = true; if (!(c[x] + c[nx[x]] + cl == 3 && min({c[x], c[nx[x]], cl}) == 0)) flag2 = false; c[x] = cl; nx[x] = y; } if (!flag1) printf("neispravna triangulacija\n"); else if (!flag2) printf("neispravno bojenje\n"); else printf("tocno\n"); return 0; }

Compilation message (stderr)

checker.cpp: In function 'int main()':
checker.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |  scanf("%d%d", &t, &n);
      |  ~~~~~^~~~~~~~~~~~~~~~
checker.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |   scanf(" %c", &x);
      |   ~~~~~^~~~~~~~~~~
checker.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   39 |   scanf("%d%d%d", &a, &b, &c); a--, b--, 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...