Submission #291476

#TimeUsernameProblemLanguageResultExecution timeMemory
291476groeneprofTriangles (CEOI18_tri)C++14
100 / 100
37 ms2352 KiB
#include <bits/stdc++.h> #include "trilib.h" #define P(a) do{if(debug) cout<<a<<endl;} while(false) #define H(a) P(#a<<": "<<a) #define FR(i,a,b) for(int i = (a); i<(b); i++) #define F(i,n) FR(i,0,n) const int debug = 0; using namespace std; bool comp(int a, int b){ return is_clockwise(1,a,b); } int n; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); n = get_n(); vector<int> v1 = {2},v2; for(int i = 3; i<=n; i++){ if(is_clockwise(1,2,i)){ v1.push_back(i); } else{ v2.push_back(i); } } P("aaaaaaaa"); sort(v1.begin(),v1.end(),comp); P("a"); sort(v2.begin(),v2.end(),comp); P("b"); v1.push_back(1); v1.insert(v1.end(),v2.begin(),v2.end()); deque<int> dq; if(debug){ for(int i : v1){ cout<<i<<" "; } cout<<endl; } for(int i : v1){ while(true){ if(dq.size()<2 || is_clockwise(dq[dq.size()-2],dq[dq.size()-1],i)) { dq.push_back(i); break; } else{ dq.pop_back(); } } } P("c"); if(debug){ for(int i : dq){ cout<<i<<" "; } cout<<endl; } bool a = is_clockwise(dq[dq.size()-1],dq[0],dq[1]); bool b = is_clockwise(dq[dq.size()-2],dq[dq.size()-1],dq[0]); while(!a || !b){ if(!a){ dq.pop_front(); } if(!b){ dq.pop_back(); } if(debug){ for(int i : dq){ cout<<i<<" "; } cout<<endl; } a = is_clockwise(dq[dq.size()-1],dq[0],dq[1]); b = is_clockwise(dq[dq.size()-2],dq[dq.size()-1],dq[0]); } give_answer(dq.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...