제출 #96414

#제출 시각아이디문제언어결과실행 시간메모리
96414easruiTriangles (CEOI18_tri)C++14
0 / 100
3 ms504 KiB
#include <bits/stdc++.h> #include "trilib.h" using namespace std; const int MN = 4e4+5; vector<int> U,D; int stD[MN],stU[MN],cntD,cntU,s,e,ans; bool isend; bool cmp(int a, int b) { return is_clockwise(1,a,b); } int main() { int N = get_n(); for(int i=3; i<=N; i++){ if(is_clockwise(1,2,i)) D.push_back(i); else U.push_back(i); } sort(D.begin(),D.end(),cmp); sort(U.begin(),U.end(),cmp); stD[0] = 1; stD[1] = 2; cntD = 1; for(int x : D){ while(!is_clockwise(stD[cntD-1],stD[cntD],x)) cntD--; stD[++cntD] = x; } if(D.size()) while(!is_clockwise(stD[cntD-1],stD[cntD],1)) cntD--; stU[0] = 2; stU[1] = 1; cntU = 1; for(int x : U){ while(!is_clockwise(stU[cntU-1],stU[cntU],x)) cntU--; stU[++cntU] = x; } if(U.size()) while(!is_clockwise(stU[cntU-1],stU[cntU],2)) cntU--; ans = cntD+cntU; if(!D.size() || !U.size()){ give_answer(ans); return 0; } if(!is_clockwise(stD[cntD],stU[1],stU[2])){ s = cntD, e = 2; isend = false; while(!isend){ isend = true; if(!is_clockwise(stD[s-1],stD[s],stU[e])){ s--; isend = false; } if(!is_clockwise(stD[s],stU[e],stU[e+1])){ e++; isend = false; } } ans -= (cntD-s) + (e-1); } if(!is_clockwise(stU[cntU],stD[1],stD[2])){ s = cntU, e = 2; isend = false; while(!isend){ isend = true; if(!is_clockwise(stU[s-1],stU[s],stD[e])){ s--; isend = false; } if(!is_clockwise(stU[s],stD[e],stD[e+1])){ e++; isend = false; } } ans -= (cntU-s) + (e-1); } give_answer(ans); }
#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...