Submission #405481

#TimeUsernameProblemLanguageResultExecution timeMemory
405481ollelTriangles (CEOI18_tri)C++14
0 / 100
3084 ms296 KiB
#include <bits/stdc++.h> #include <iostream> #include "trilib.h" using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef tuple<int,int,int> tiii; #define rep(i,a,b) for(int i = a; i < b; i++) #define pb push_back int n, guesses = 999995; map<tiii, bool> cw; // // bool is_clockwise(int a, int b, int c) { // cout << "clockwise? " << a << " " << b << " " << c << endl; // bool ans; // cin >> ans; // return ans; // } // // int get_n(){ // int N; cin >> N; return N; // } bool clockwise(int a, int b, int c){ tiii t = make_tuple(a, b, c); if (cw.find(t) != cw.end()) return cw[t]; guesses--; bool ans = is_clockwise(a, b, c); cw[{a, b, c}] = cw[{b, c, a}] = cw[{c, a, b}] = ans; cw[{a, c, b}] = cw[{c, b, a}] = cw[{b, a, c}] = !ans; return ans; } vi sort_hull() { int sortby = 1; vi s = {2}; rep(i, 3, n + 1) { int low = 0, high = s.size(), mid; while (high - low > 1) { mid = (high + low) / 2; if (clockwise(sortby, i, s[mid])) high = mid; else low = mid; } if (clockwise(sortby, i, s[low])) s.insert(s.begin() + low, i); else s.insert(s.begin() + low + 1, i); } s.insert(s.begin(), sortby); return s; } int main() { n = get_n(); int sortby = 1; vi s = sort_hull(); int ans = n; vi nxt(n+1); rep(i,0,n-1) nxt[s[i]] = s[i + 1]; nxt[s[n - 1]] = s[0]; int cur = 1; bool lastupd = 1; while (true) { if (!clockwise(cur, nxt[cur], nxt[nxt[cur]])) { ans--; nxt[cur] = nxt[nxt[cur]]; lastupd = cur; } cur = nxt[cur]; if (lastupd == cur) break; } cout << ans << endl; }

Compilation message (stderr)

tri.cpp: In function 'int main()':
tri.cpp:62:7: warning: unused variable 'sortby' [-Wunused-variable]
   62 |   int sortby = 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...