Submission #503666

#TimeUsernameProblemLanguageResultExecution timeMemory
503666andrei_boacaTriangles (CEOI18_tri)C++17
75 / 100
1859 ms205856 KiB
#include <bits/stdc++.h> #include "trilib.h" //#include "trilib.c" using namespace std; map<vector<int>,bool> f; set<int> border; vector<int> stiva,v; int root; bool use[40005]; bool isgood(int a,int b,int c) { vector<int> v; v.push_back(a); v.push_back(b); v.push_back(c); sort(v.begin(),v.end()); if(f.count(v)==0) f[v]=is_clockwise(v[0],v[1],v[2]); bool ans=f[v]; int nr=0; if(a!=v[0]) nr++; if(b!=v[1]) nr++; if(c!=v[2]) nr++; if(nr%2==0&&nr>0) ans=!ans; return ans; } bool comp(int a, int b) { if(isgood(root,a,b)) return 1; return 0; } int main() { int n; n=get_n(); int i=1; while(border.empty()) { int good=2; int val=-1; int j=2; if(i==2) j=1; for(int k=1;k<=n;k++) if(k!=i&&k!=j) if(isgood(i,j,k)) j=k; for(int k=1;k<=n;k++) if(k!=i&&k!=j) if(isgood(i,j,k)) good=0; if(good) { border.insert(i); border.insert(j); } else i=j; } int j=*border.begin(); stiva.push_back(j); root=j; for(int i=1;i<=n;i++) if(i!=j) v.push_back(i); sort(v.begin(),v.end(),comp); stiva.push_back(v[0]); for(int i=1;i<v.size();i++) { int nod=v[i]; while(stiva.size()>=2) { int lg=stiva.size(); int b=stiva[lg-1]; int a=stiva[lg-2]; if(!isgood(a,b,nod)) stiva.pop_back(); else break; } stiva.push_back(nod); } int ans=stiva.size(); give_answer(ans); return 0; }

Compilation message (stderr)

tri.cpp: In function 'int main()':
tri.cpp:45:17: warning: unused variable 'val' [-Wunused-variable]
   45 |             int val=-1;
      |                 ^~~
tri.cpp:73:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     for(int i=1;i<v.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...