Submission #338682

#TimeUsernameProblemLanguageResultExecution timeMemory
338682NicolaAbusaad2014Gap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
/** * Prof.Nicola **/ #include "gap.h" #include <bits/stdc++.h> using namespace std; template<class T>void re(T&x){cin>>x;} template<class T1,class T2> void re(pair<T1,T2>&x){re(x.first);re(x.second);} template<class T>void re(vector<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}} template<class T>void re(deque<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}} template<class T1,class T2> pair<T1,T2> mp(T1&x,T2&z){return make_pair(x,z);} long long n; set<long long>s; set<long long>::iterator a,b; void solve(long long l,long long r) { long long mx,mn; MinMax(l, r, &mn, &mx); if(mn==-1){ return; } s.insert(mn); s.insert(mx); if((long long)s.size()==n){ return; } if(mn+1>=mx){ return; } if(mn+3>=mx){ solve(mn+1,mx-1); return; } solve(mn+1,((mx+mn)/2)); if(s.size()==n){ return; } solve(((mx+mn)/2)+1,mx-1); return; } long long findGap(int T, int N) { n=N; if(T==1){ long long l=0,r=1e18,mn,mx; while(s.size()<N){ MinMax(l,r,&mn,&mx); l=mn+1; r=mx-1; s.insert(mn); s.insert(mx); } a=s.begin(); b=s.begin(); b++; long long ans=0; for(long i=1;i<s.size();i++){ ans=max(ans,(*b)-(*a)); a++; b++; } } else{ long long l=0,r=1e18,ans=0; solve(l,r); a=s.begin(); b=s.begin(); b++; long long ans=0; for(long i=1;i<s.size();i++){ ans=max(ans,(*b)-(*a)); a++; b++; } } return ans; }

Compilation message (stderr)

gap.cpp: In function 'void solve(long long int, long long int)':
gap.cpp:36:16: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   36 |     if(s.size()==n){
      |        ~~~~~~~~^~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:47:19: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |     while(s.size()<N){
      |           ~~~~~~~~^~
gap.cpp:58:19: warning: comparison of integer expressions of different signedness: 'long int' and 'std::set<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(long i=1;i<s.size();i++){
      |                  ~^~~~~~~~~
gap.cpp:70:19: error: redeclaration of 'long long int ans'
   70 |         long long ans=0;
      |                   ^~~
gap.cpp:65:30: note: 'long long int ans' previously declared here
   65 |         long long l=0,r=1e18,ans=0;
      |                              ^~~
gap.cpp:71:23: warning: comparison of integer expressions of different signedness: 'long int' and 'std::set<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |         for(long i=1;i<s.size();i++){
      |                      ~^~~~~~~~~
gap.cpp:77:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   77 |  return ans;
      |         ^~~
      |         abs