Submission #898187

#TimeUsernameProblemLanguageResultExecution timeMemory
898187alexddTriangles (CEOI18_tri)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> #include "trilib.h" using namespace std; int n,centru; bool cmp(int x, int y) { if(is_clockwise(centru,x,y)) return 1; return 0; } bool is_inter(int x, int a, int b, int c)///is x in the triangle (a,b,c) { if(!is_clockwise(a,b,c)) return is_inter(x,c,b,a); if(is_clockwise(x,b,c) && is_clockwise(x,a,b) && is_clockwise(x,c,a)) return 1; return 0; } signed main() { n = get_n(); if(n==3) { give_answer(3); return 0; } centru=1; vector<int> ord; for(int i=1;i<=n;i++) if(i!=centru) ord.push_back(i); sort(ord.begin(),ord.end(),cmp); for(int i=0;i+1<ord.size();i++) { if(!is_clockwise(centru,ord[i],ord[(i+1)%(n-1)])) { while(1) n=0; } } vector<int> hull; hull.push_back(ord[0]); hull.push_back(ord[1]); for(int i=2;i<ord.size();i++) { while((int)hull.size()>=2 && is_inter(hull.back(), centru, hull[(int)hull.size()-2], ord[i])) hull.pop_back(); //if((int)hull.size()<2 || !is_inter(ord[i], centru, hull.back(), hull[0])) bool bl=1; if((int)hull.size()>=2) { for(int j=0;j<hull.size();j++) { if(is_inter(ord[i], centru,hull[j],hull[(j+1)%((int)hull.size())])) { bl=0; break; } } } if(bl) hull.push_back(ord[i]); } int idk=1; if((int)hull.size()>=3) { for(int i=0;i<hull.size();i++) { /*if(!is_clockwise(hull[i],hull[(i+1)%((int)hull.size())],hull[(i+2)%((int)hull.size())])) { while(1) n=0; }*/ if(is_inter(centru,hull[i],hull[(i+1)%((int)hull.size())],hull[(i+2)%((int)hull.size())])) { idk=0; } } } give_answer(max(3,(int)hull.size() + idk)); }

Compilation message (stderr)

tri.cpp: In function 'int main()':
tri.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i+1<ord.size();i++)
      |                 ~~~^~~~~~~~~~~
tri.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i=2;i<ord.size();i++)
      |                 ~^~~~~~~~~~~
tri.cpp:52:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             for(int j=0;j<hull.size();j++)
      |                         ~^~~~~~~~~~~~
tri.cpp:67:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         for(int i=0;i<hull.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...