Submission #73597

#TimeUsernameProblemLanguageResultExecution timeMemory
73597zscoderTriangles (CEOI18_tri)C++17
0 / 100
3 ms488 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include "trilib.h" using namespace std; using namespace __gnu_pbds; #define fi first #define se second #define mp make_pair #define pb push_back typedef long long ll; typedef pair<int,int> ii; typedef vector<int> vi; typedef long double ld; typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds; int nn; int god; bool is_cl(int x, int y, int z) { return is_clockwise(x+1,y+1,z+1); } bool cmp(int x, int y) { return !is_cl(god,x,y); } int ans; vector<int> ez_convex_hull(vector<int> vec) { if(vec.size()<=2) return vec; vector<int> S; S.pb(vec[0]); S.pb(vec[1]); S.pb(vec[2]); int dir = is_cl(vec[0],vec[1],vec[2]); for(int i=3;i<vec.size();i++) { int u=vec[i]; while(S.size()>2&&is_cl(S[int(S.size())-2], S[int(S.size())-1], u)!=dir) { S.pop_back(); } S.pb(u); } return S; } int main() { nn = get_n(); vi U, D; god=0; for(int i=2;i<nn;i++) { if(is_cl(0,1,i)) { U.pb(i); } else { D.pb(i); } } stable_sort(U.begin(),U.end(),cmp); stable_sort(D.begin(),D.end(),cmp); D.pb(0); U.pb(1); for(int x:U) { cerr<<x<<' '; } cerr<<'\n'; for(int x:D) { cerr<<x<<' '; } cerr<<'\n'; U = ez_convex_hull(U); D = ez_convex_hull(D); vector<int> combined; for(int v:U) combined.pb(v); for(int v:D) combined.pb(v); for(int v:combined) { cerr<<v<<' '; } cerr<<'\n'; combined = ez_convex_hull(combined); deque<int> dq; for(int v:combined) { cerr<<v<<' '; dq.pb(v); } cerr<<'\n'; while(1) { bool quit=1; int x = dq.back(); dq.pop_back(); if(dq.size()>=3&&is_cl(dq.back(), x, dq.front())) { quit=0; } else dq.pb(x); x = dq.front(); dq.pop_front(); if(dq.size()>=3&&!is_cl(dq.front(), x, dq.back())) { quit=0; } else dq.push_front(x); if(quit) break; } give_answer(dq.size()); }

Compilation message (stderr)

tri.cpp: In function 'std::vector<int> ez_convex_hull(std::vector<int>)':
tri.cpp:37:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=3;i<vec.size();i++)
              ~^~~~~~~~~~~
#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...