Submission #400595

#TimeUsernameProblemLanguageResultExecution timeMemory
400595A_DGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include "gap.h" #include <bits/stdc++.h> #define ll long long using namespace std; ll l2=0,r2=1e18; ll *l1=&l2; ll *r1=&r2; ll s(ll m) { vector<ll> vec; ll l=0,r=1e18; l2=0,r2=1e18; while(l<=r&&m--){ MinMax(l,r,l1,r1); if(l2!=-1)vec.push_back(l2); if(r2!=-1)vec.push_back(r2); l=l2; r=r2; l++; r--; } sort(vec.begin(),vec.end()); ll ans=1; for(ll i=1;i<vec.size();i++)ans=max(ans,vec[i]-vec[i-1]); return ans; } vector <ll> vec; set <ll> st int n; void bs(int l,int r) { if(l>r||n==0)return; int mid=(l+r)/2; MinMax(l,r,l1,r1); if(l2==-1){ bs(mid+1,r); } else if(l2==r2){ vec.push_back(l2); n--; st.insert(l2); bs(mid+1,r); } else{ n-=2; vec.push_back(l2); vec.push_back(r2); bs(l2+1,r2-1); bs(mid+1,r); } } ll s2() { st.clear();vec.clear(); bs(0,1e18); ll ans=1; sort(vec.begin(),vec.end()); for(ll i=1;i<vec.size();i++)ans=max(ans,vec[i]-vec[i-1]); return ans; } long long findGap(int T, int N) { n=N; if(T==1)return s((N+1)/2); else{ return s2(); } }

Compilation message (stderr)

gap.cpp: In function 'long long int s(long long int)':
gap.cpp:27:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(ll i=1;i<vec.size();i++)ans=max(ans,vec[i]-vec[i-1]);
      |                ~^~~~~~~~~~~
gap.cpp: At global scope:
gap.cpp:32:1: error: expected initializer before 'int'
   32 | int n;
      | ^~~
gap.cpp: In function 'void bs(int, int)':
gap.cpp:35:13: error: 'n' was not declared in this scope
   35 |     if(l>r||n==0)return;
      |             ^
gap.cpp:43:9: error: 'n' was not declared in this scope
   43 |         n--;
      |         ^
gap.cpp:44:9: error: 'st' was not declared in this scope; did you mean 's'?
   44 |         st.insert(l2);
      |         ^~
      |         s
gap.cpp:48:9: error: 'n' was not declared in this scope
   48 |         n-=2;
      |         ^
gap.cpp: In function 'long long int s2()':
gap.cpp:57:5: error: 'st' was not declared in this scope; did you mean 's2'?
   57 |     st.clear();vec.clear();
      |     ^~
      |     s2
gap.cpp:58:10: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   58 |     bs(0,1e18);
      |          ^~~~
gap.cpp:61:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(ll i=1;i<vec.size();i++)ans=max(ans,vec[i]-vec[i-1]);
      |                ~^~~~~~~~~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:66:5: error: 'n' was not declared in this scope
   66 |     n=N;
      |     ^