Submission #400592

#TimeUsernameProblemLanguageResultExecution timeMemory
400592A_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 s(ll m)
{
    vector<ll> vec;
    ll l=0,r=1e18;
    ll l2=0,r2=1e18;
    ll *l1=&l2;
    ll *r1=&r2;
    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
ll l2=0,r2=1e18;
ll *l1=&l2;
ll *r1=&r2;
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(int n)
{ 
    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)
{
    if(T==1)return s((N+1)/2);
    else{
        return s2(int N);
    }
}

Compilation message (stderr)

gap.cpp: In function 'long long int s(long long int)':
gap.cpp:26: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]
   26 |     for(ll i=1;i<vec.size();i++)ans=max(ans,vec[i]-vec[i-1]);
      |                ~^~~~~~~~~~~
gap.cpp: At global scope:
gap.cpp:5:12: error: expected initializer before 'long'
    5 | #define ll long long
      |            ^~~~
gap.cpp:31:1: note: in expansion of macro 'll'
   31 | ll l2=0,r2=1e18;
      | ^~
gap.cpp:32:9: error: 'l2' was not declared in this scope; did you mean 'l1'?
   32 | ll *l1=&l2;
      |         ^~
      |         l1
gap.cpp:33:9: error: 'r2' was not declared in this scope; did you mean 'r1'?
   33 | ll *r1=&r2;
      |         ^~
      |         r1
gap.cpp: In function 'void bs(int, int)':
gap.cpp:36:13: error: 'n' was not declared in this scope
   36 |     if(l>r||n==0)return;
      |             ^
gap.cpp:39:8: error: 'l2' was not declared in this scope; did you mean 'l'?
   39 |     if(l2==-1){
      |        ^~
      |        l
gap.cpp:42:17: error: 'r2' was not declared in this scope; did you mean 'r'?
   42 |     else if(l2==r2){
      |                 ^~
      |                 r
gap.cpp:44:9: error: 'n' was not declared in this scope
   44 |         n--;
      |         ^
gap.cpp:45:9: error: 'st' was not declared in this scope; did you mean 's'?
   45 |         st.insert(l2);
      |         ^~
      |         s
gap.cpp:49:9: error: 'n' was not declared in this scope
   49 |         n-=2;
      |         ^
gap.cpp: In function 'long long int s2(int)':
gap.cpp:58:5: error: 'st' was not declared in this scope; did you mean 's2'?
   58 |     st.clear();vec.clear();
      |     ^~
      |     s2
gap.cpp:59:10: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   59 |     bs(0,1e18);
      |          ^~~~
gap.cpp:62: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]
   62 |     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:69:19: error: expected primary-expression before 'int'
   69 |         return s2(int N);
      |                   ^~~