Submission #1111122

# Submission time Handle Problem Language Result Execution time Memory
1111122 2024-11-11T14:37:02 Z imarn Gap (APIO16_gap) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define pp pair<ll,int>
#define ub(x,i) upper_bound(all(x),i)-x.begin()
#include "gap.h"
using namespace std;
long long cal1(int n){
    ll a[n];
    ll l=0,r=n-1;
    ll mn=0,mx=0;
    ll tl=0,tr=1e18;
    while(l<=r){
        MinMax(tl,tr,a[l],a[r]);
        tl=a[l]+1,tr=a[r]-1;
        l++,r--;
    }ll rs=0;
    for(int i=1;i<n;i++)rs=max(rs,a[i]-a[i-1]);
    return rs;
}
ll cal2(int n){
    ll mn,mx;
    ll tl=0,tr=1e18;
    MinMax(tl,tr,mn,mx);
    ll ans = (mx-mn-1)/(n-1)+1;
    ll cl=-1,cr=-1;
    ll rl = mn+1,rr=mn+ans;
    while(1){
        MinMax(rl,rr,cl,cr);
        if(cl==-1){
            rl = rr+1;
            rr = rr+ans;
        }
        else {
            ans = max(ans,cl-mn);
            mn=cr;
            rl=rr+1;
            rr=rr+ans;
            if(cr==mx)break;
        }
    }return ans;
}
long long findGap(int T, int N)
{
	if(T==1)return cal1(N);
	else return cal2(N);
}
/*int main(){m=5;
    b[0]=2;
    b[1]=3;
    b[2]=6;
    b[3]=500;
    b[4]=10000;
    cout<<findGap(2,5);
}*/

Compilation message

gap.cpp: In function 'long long int cal1(int)':
gap.cpp:22:25: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   22 |         MinMax(tl,tr,a[l],a[r]);
      |                      ~~~^
      |                         |
      |                         long long int
In file included from gap.cpp:14:
gap.h:1:35: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                   ^~~~~~~~~~
gap.cpp:22:30: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   22 |         MinMax(tl,tr,a[l],a[r]);
      |                           ~~~^
      |                              |
      |                              long long int
In file included from gap.cpp:14:
gap.h:1:47: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                               ^~~~~~~~~~
gap.cpp:19:8: warning: unused variable 'mn' [-Wunused-variable]
   19 |     ll mn=0,mx=0;
      |        ^~
gap.cpp:19:13: warning: unused variable 'mx' [-Wunused-variable]
   19 |     ll mn=0,mx=0;
      |             ^~
gap.cpp: In function 'long long int cal2(int)':
gap.cpp:32:18: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   32 |     MinMax(tl,tr,mn,mx);
      |                  ^~
      |                  |
      |                  long long int
In file included from gap.cpp:14:
gap.h:1:35: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                   ^~~~~~~~~~
gap.cpp:32:21: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   32 |     MinMax(tl,tr,mn,mx);
      |                     ^~
      |                     |
      |                     long long int
In file included from gap.cpp:14:
gap.h:1:47: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                               ^~~~~~~~~~
gap.cpp:37:22: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   37 |         MinMax(rl,rr,cl,cr);
      |                      ^~
      |                      |
      |                      long long int
In file included from gap.cpp:14:
gap.h:1:35: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                   ^~~~~~~~~~
gap.cpp:37:25: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   37 |         MinMax(rl,rr,cl,cr);
      |                         ^~
      |                         |
      |                         long long int
In file included from gap.cpp:14:
gap.h:1:47: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                               ^~~~~~~~~~