Submission #1095306

#TimeUsernameProblemLanguageResultExecution timeMemory
1095306alexander707070Triangles (CEOI18_tri)C++14
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "trilib.h" #define MAXN 100007 using namespace std; int n; /*static long long *x, *y; static int queries=0; static void init() { static int is_inited=0; if (is_inited) return; is_inited=1; assert(scanf("%d", &n)==1); x=(long long*)malloc((n+1)*sizeof(long long)); y=(long long*)malloc((n+1)*sizeof(long long)); for (int i=1; i<=n; i++){ x[i]=rand()%100+1; y[i]=rand()%100+1; //cin>>x[i]>>y[i]; //assert(scanf("%lld%lld", &x[i], &y[i])==2); } } int get_n() { init(); return n; } int is_clockwise(int a, int b, int c) { init(); assert(a>=1 && a<=n); assert(b>=1 && b<=n); assert(c>=1 && c<=n); assert(a!=b && a!=c && b!=c); queries++; if(queries == 1000 * 1000 + 1) printf("Too many queries!"); return (x[b]-x[a])*(y[c]-y[a])-(x[c]-x[a])*(y[b]-y[a])<0; } void give_answer(int s) { init(); printf("%d\n", s); }*/ bool cmp(int x,int y){ return is_clockwise(1,x,y); } vector<int> l,r,res; int s[MAXN]; int main(){ srand(42069); n=get_n(); for(int i=3;i<=n;i++){ if(!is_clockwise(1,2,i)){ l.push_back(i); }else{ r.push_back(i); } } sort(l.begin(),l.end(),cmp); sort(r.begin(),r.end(),cmp); s[1]=1; for(int i=0;i<l.size();i++){ s[i+2]=l[i]; } s[l.size()+2]=2; for(int i=0;i<r.size();i++){ s[l.size()+3+i]=r[i]; } for(int i=1;i<=n;i++){ while(res.size()>=2 and !is_clockwise(res[res.size()-2],res[res.size()-1],s[i])){ res.pop_back(); } res.push_back(s[i]); } while(res.size()>=2 and !is_clockwise(res[res.size()-2],res[res.size()-1],res.front())){ res.pop_back(); } give_answer(res.size()); return 0; }

Compilation message (stderr)

tri.cpp: In function 'int main()':
tri.cpp:76:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |     for(int i=0;i<l.size();i++){
      |                 ~^~~~~~~~~
tri.cpp:82:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |     for(int i=0;i<r.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...