제출 #128430

#제출 시각아이디문제언어결과실행 시간메모리
128430TadijaSebezTriangles (CEOI18_tri)C++11
100 / 100
32 ms2160 KiB
#include "trilib.h" #include <bits/stdc++.h> using namespace std; #define pb push_back bool comp(int i, int j){ return is_clockwise(1,i,j);} int main() { int n=get_n(); vector<int> v[2]={{2},{2}},u[2]; for(int i=3;i<=n;i++) v[is_clockwise(1,2,i)].pb(i); for(int t=0;t<2;t++) { sort(v[t].begin(),v[t].end(),comp); for(int i:v[t]) { while(u[t].size()>1 && !is_clockwise(u[t][u[t].size()-2],u[t].back(),i)) u[t].pop_back(); u[t].pb(i); } if(t) reverse(u[t].begin(),u[t].end()); u[t].insert(u[t].begin(),1); } if(min(u[0].size(),u[1].size())==2) { give_answer(max(u[0].size(),u[1].size())); return 0; } for(int t=0;t<2;t++) { u[0].pop_back(); while(1) { bool ok=0; if(u[0].size()>1 && !is_clockwise(u[0][u[0].size()-2],u[0].back(),u[1].back())) u[0].pop_back(),ok=1; if(u[1].size()>1 && !is_clockwise(u[0].back(),u[1].back(),u[1][u[1].size()-2])) u[1].pop_back(),ok=1; if(!ok) break; } reverse(u[0].begin(),u[0].end()); reverse(u[1].begin(),u[1].end()); swap(u[0],u[1]); } give_answer(u[0].size()+u[1].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...