Submission #1005908

# Submission time Handle Problem Language Result Execution time Memory
1005908 2024-06-23T07:45:29 Z vjudge1 Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "gap.h"
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#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 vl vector<ll>
using namespace std;
/*const int mxn=3e5+5;
multiset<ll>ms;
void MinMax(ll x,ll y,ll &x1,ll &y1){
    x1=*ms.lower_bound(x);
    y1=*prev(ms.upper_bound(y));
}*/
ll sol1(int n){
    ll mn=0,mx=1e18;
    int l=1,r=n;
    ll a[n+1];
    while(l<r){
        ll s,t;
        MinMax(mn,mx,s,t);
        a[l++]=s;a[r--]=t;
    }ll ans=0;
    for(int i=2;i<=n;i++)ans=max(ans,a[i]-a[i-1]);
    return ans;
}
ll sol2(int n){
    ll mn=0,mx=1e18;
    ll s,t;MinMax(mn,mx,s,t);
    ll add = (t-s-1)/(n-1)+1;
    ll ans=0;
    while(s<t){
        ll cmn=s,cmx=s;
        ll tt=1;
        while(1){
            MinMax(s,s+tt*add,cmn,cmx);
            if(cmn!=cmx)break;
            tt++;
        }ll cmn2=cmn,cmx2=cmx;
        MinMax(s+(tt-1)*add,s+tt*add,cmn2,cmx2);
        if(cmn2==cmx2)cmn2=cmn;
        ans=max(ans,cmx2-cmn2);
        s=cmx2;
    }return ans;
}
long long findGap(int T, int N){
    if(T==1)return sol1(N);
    else return sol2(N);
}
/*int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        int x;cin>>x;ms.insert(x);
    }for(auto it : ms)cout<<it<<' ';cout<<'\n';
    cout<<findGap(2,n);
}*/

Compilation message

gap.cpp: In function 'long long int sol1(int)':
gap.cpp:10:11: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   10 | #define s second
      |           ^~~~~~
      |           |
      |           long long int
gap.cpp:28:22: note: in expansion of macro 's'
   28 |         MinMax(mn,mx,s,t);
      |                      ^
In file included from gap.cpp:2:
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:28:24: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   28 |         MinMax(mn,mx,s,t);
      |                        ^
      |                        |
      |                        long long int
In file included from gap.cpp:2:
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: In function 'long long int sol2(int)':
gap.cpp:10:11: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   10 | #define s second
      |           ^~~~~~
      |           |
      |           long long int
gap.cpp:36:25: note: in expansion of macro 's'
   36 |     ll s,t;MinMax(mn,mx,s,t);
      |                         ^
In file included from gap.cpp:2:
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:36:27: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   36 |     ll s,t;MinMax(mn,mx,s,t);
      |                           ^
      |                           |
      |                           long long int
In file included from gap.cpp:2:
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:43:31: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   43 |             MinMax(s,s+tt*add,cmn,cmx);
      |                               ^~~
      |                               |
      |                               long long int
In file included from gap.cpp:2:
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:43:35: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   43 |             MinMax(s,s+tt*add,cmn,cmx);
      |                                   ^~~
      |                                   |
      |                                   long long int
In file included from gap.cpp:2:
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:47:38: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   47 |         MinMax(s+(tt-1)*add,s+tt*add,cmn2,cmx2);
      |                                      ^~~~
      |                                      |
      |                                      long long int
In file included from gap.cpp:2:
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:47:43: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   47 |         MinMax(s+(tt-1)*add,s+tt*add,cmn2,cmx2);
      |                                           ^~~~
      |                                           |
      |                                           long long int
In file included from gap.cpp:2:
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*);
      |                                               ^~~~~~~~~~