Submission #852055

# Submission time Handle Problem Language Result Execution time Memory
852055 2023-09-21T07:39:29 Z 8pete8 Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset>
#include "gap.h"
using namespace std;
#define ll long long
#define f first
#define endl "\n"
//#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#define int long long
const int mxn=1e5,mod=1000000007,lg=20,root=1000,inf=1e18;
void setIO(string name) {
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
int findgap(int T,int N){
    int mn,mx;
    MinMax(0,1e18,&mn,&mx);
    if(N==2)return mx-mn;
    int ans=0;
    if(T==1){
        int lmn=mn,lmx=mx;
        while(mn<mx){
            MinMax(lmn+1,lmx-1,mn,mx);
            ans=max({ans,mn-lmn,lmx-mx});
            lmn=mn;
            lmx=mx;
            if(mn==-1)break;
        }
        return ans;
    }
    ans=((mx-mn-1)+(N-2))/(N-2);//min max gap
    int add=0,cur=mn;
    for(int i=0;i<N;i++){
        MinMax(cur+1,cur+ans,mn,mx);
        if(mn==-1)add+=(ans);
        else cur=mx,ans=max(ans,add+(mn-cur));
    }
    cout<<ans;
}

Compilation message

gap.cpp: In function 'long long int findgap(long long int, long long int)':
gap.cpp:44:32: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   44 |             MinMax(lmn+1,lmx-1,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:44:35: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   44 |             MinMax(lmn+1,lmx-1,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:55:30: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   55 |         MinMax(cur+1,cur+ans,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:55:33: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   55 |         MinMax(cur+1,cur+ans,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: In function 'void setIO(std::string)':
gap.cpp:33:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gap.cpp:34:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gap.cpp: In function 'long long int findgap(long long int, long long int)':
gap.cpp:60:1: warning: control reaches end of non-void function [-Wreturn-type]
   60 | }
      | ^