Submission #1095039

#TimeUsernameProblemLanguageResultExecution timeMemory
1095039alexander707070Triangles (CEOI18_tri)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "trilib.h" #define MAXN 100007 using namespace std; int n; vector<int> combine(vector<int> a,vector<int> b){ for(int test=0;test<10;test++){ int pos=rand()%int(a.size()); vector<int> res; for(int i=pos;i<a.size();i++)res.push_back(a[i]); for(int i=0;i<pos;i++)res.push_back(a[i]); int pos2=rand()%int(b.size()); for(int i=pos2;i<b.size();i++){ while(res.size()>=2 and !is_clockwise(res[res.size()-2],res[res.size()-1],b[i])){ res.pop_back(); } res.push_back(b[i]); } for(int i=0;i<pos2;i++){ while(res.size()>=2 and !is_clockwise(res[res.size()-2],res[res.size()-1],b[i])){ res.pop_back(); } res.push_back(b[i]); } while(res.size()>=2 and !is_clockwise(res[res.size()-2],res[res.size()-1],a[pos])){ res.pop_back(); } bool b1=false,b2=false; for(int i=0;i<res.size();i++){ for(int f:a){ if(f==res[i] or f==res[(i+1)%res.size()])continue; b1=(b1 or is_clockwise(res[i],f,res[(i+1)%res.size()])); b2=(b2 or !is_clockwise(res[i],f,res[(i+1)%res.size()])); if(b1 and b2)break; } for(int f:b){ if(f==res[i] or f==res[(i+1)%res.size()])continue; b1=(b1 or is_clockwise(res[i],f,res[(i+1)%res.size()])); b2=(b2 or !is_clockwise(res[i],f,res[(i+1)%res.size()])); if(b1 and b2)break; } } if(!(b1 and b2))return res; } } vector<int> solve(vector<int> w){ if(w.size()<=2)return w; if(w.size()==3){ if(!is_clockwise(w[0],w[1],w[2])){ swap(w[0],w[2]); } return w; } int r1=rand()%int(w.size()); int r2=r1; while(r2==r1){ r2=rand()%int(w.size()); } for(int i=0;i<w.size();i++){ if(i==r1 or i==r2)continue; if(is_clockwise(r1,i,r2))l.push_back(i); else r.push_back(i); } vector<int> convl=solve(l); vector<int> convr=solve(r); vector<int> sol=combine(convl,{r1,r2}); sol=combine(sol,convr); return sol; } vector<int> perm; int main(){ n=get_n(); for(int i=1;i<=n;i++){ perm.push_back(i); } vector<int> res=solve(perm); give_answer(res.size()); return 0; }

Compilation message (stderr)

tri.cpp: In function 'std::vector<int> combine(std::vector<int>, std::vector<int>)':
tri.cpp:15:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for(int i=pos;i<a.size();i++)res.push_back(a[i]);
      |                       ~^~~~~~~~~
tri.cpp:20:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for(int i=pos2;i<b.size();i++){
      |                        ~^~~~~~~~~
tri.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int i=0;i<res.size();i++){
      |                     ~^~~~~~~~~~~
tri.cpp: In function 'std::vector<int> solve(std::vector<int>)':
tri.cpp:80:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for(int i=0;i<w.size();i++){
      |                 ~^~~~~~~~~
tri.cpp:83:34: error: 'l' was not declared in this scope
   83 |         if(is_clockwise(r1,i,r2))l.push_back(i);
      |                                  ^
tri.cpp:84:14: error: 'r' was not declared in this scope
   84 |         else r.push_back(i);
      |              ^
tri.cpp:87:29: error: 'l' was not declared in this scope
   87 |     vector<int> convl=solve(l);
      |                             ^
tri.cpp:88:29: error: 'r' was not declared in this scope; did you mean 'r2'?
   88 |     vector<int> convr=solve(r);
      |                             ^
      |                             r2
tri.cpp: In function 'std::vector<int> combine(std::vector<int>, std::vector<int>)':
tri.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
   62 | }
      | ^