Submission #267159

#TimeUsernameProblemLanguageResultExecution timeMemory
267159Kenzo_1114Triangles (CEOI18_tri)C++17
0 / 100
1 ms384 KiB
#include<bits/stdc++.h> #include"trilib.h" using namespace std; const int MAXN = 40010; /* int get_n() { int aux; scanf("%d", &aux); return aux; } bool is_clockwise(int a, int b, int c) { char aux; printf("? %d %d %d\n", a, b, c); scanf(" %c", &aux); return (aux == 'y'); } void give_answer(int s) { printf("%d\n", s); } */ set<pair<int, int> > ch; set<pair<int, int> > :: iterator it; bool marc[MAXN], ans[MAXN]; int adj[MAXN]; int main () { int n = get_n(); if(!is_clockwise(1, 2, 3)) ch.insert({2, 1}), ch.insert({3, 2}), ch.insert({1, 3}); else ch.insert({1, 2}), ch.insert({2, 3}), ch.insert({3, 1}); marc[1] = marc[2] = marc[3] = true; while(!ch.empty()) { int A = 0, B = 0, C = 0; vector<pair<int, int> > true_border; for(it = ch.begin(); it != ch.end(); it++) { int a = (*it).first; int b = (*it).second; for(int c = 1; c <= n; c++) { if(marc[c] || a == c || b == c || a == b) continue; if(!is_clockwise(a, b, c)) { marc[c] = true; A = a, B = b, C = c; break; } } if(A) break; else true_border.push_back((*it)), ans[a] = ans[b] = true, adj[a] = b;// marc[a] = marc[b] = true; } for(int i = 0; i < true_border.size(); i++) ch.erase(true_border[i]); if(A) ch.insert({A, C}), ch.insert({C, B}); ch.erase({A, B}); } int bg = 1, cur = 1, sz = 0; vector<int> p, p2; while(bg <= n && !ans[bg]) bg++; p.push_back(bg); cur = adj[bg]; while(cur != bg) { p.push_back(cur); cur = adj[cur]; } for(int i = 0; i < p.size(); i++) { while(2 <= sz && !is_clockwise(p2[sz - 2], p2[sz - 1], p[i])) p2.pop_back(), sz--; p2.push_back(p[i]), sz++; } if(2 <= sz && !is_clockwise(p2[sz - 2], p2[sz - 1], bg)) sz--; give_answer(sz); /* int qtt = 0; for(int i = 1; i <= n; i++) qtt += ans[i]; give_answer(qtt); */ }

Compilation message (stderr)

tri.cpp: In function 'int main()':
tri.cpp:67:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |   for(int i = 0; i < true_border.size(); i++) ch.erase(true_border[i]);
      |                  ~~^~~~~~~~~~~~~~~~~~~~
tri.cpp:85:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |  for(int i = 0; i < p.size(); i++)
      |                 ~~^~~~~~~~~~
#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...