Submission #480739

#TimeUsernameProblemLanguageResultExecution timeMemory
480739wiwihoTriangles (CEOI18_tri)C++14
0 / 100
0 ms316 KiB
#include "trilib.h" #include<bits/stdc++.h> #define eb emplace_back #define iter(a) a.begin(), a.end() #define lsort(a) sort(iter(a)) #define uni(a) a.resize(unique(iter(a)) - a.begin()) #define printv(a, b) {\ for(auto pv : a) b << pv << " ";\ b << "\n";\ } using namespace std; typedef long long ll; void waassert(bool b){ if(b) return; cout << "OAO\n"; exit(0); } int n; vector<int> hull; int query(int a, int b, int c){ waassert(a != b && b != c && c != a); return is_clockwise(a, b, c); } void add(int id){ //cerr << "test " << id << "\n"; int m = hull.size(); bool lst = query(id, hull[m - 1], hull[0]); int p = 0; bool ok = false; for(int i = 0; i < m; i++){ bool now = query(id, hull[i], hull[(i + 1) % m]); //cerr << i << " " << hull[i] << " " << hull[(i + 1) % m] << " " << lst << " " << now << " " << p << "\n"; if(!(now && lst)) hull[p++] = hull[i]; if(now && !ok){ //cerr << "OAO " << p << " " << i << " "; //printv(hull, cerr); hull.insert(hull.begin() + p, id); i++; p++; //cerr << "OAO " << p << " " << i << " "; //printv(hull, cerr); ok = true; m = hull.size(); } lst = now; } //cerr << "ok " << p << "\n"; hull.resize(p); //printv(hull, cerr); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); n = get_n(); hull.eb(1); hull.eb(2); hull.eb(3); for(int i = 4; i <= n; i++) add(i); give_answer(hull.size()); return 0; }
#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...