답안 #579530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579530 2022-06-19T10:29:15 Z jiahng Gap (APIO16_gap) C++14
컴파일 오류
0 ms 0 KB
#include "gap.h"

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
//#define int ll
typedef pair<int32_t, int32_t> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 200010
#define INF (ll)1e9
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;

long long findGap(int T, int N)
{
    if (T == 1){
        ll curs = 0, curt = 1e18;
                FOR(i,0,(N+1)/2 - 1){
                                MinMax(curs,curt,arr + i, arr + N - i - 1);
                                            curs = arr[i] + 1;
                                                        curt = arr[N - i - 1] - 1;
                                                                }
                        ll ans = 0;
                                FOR(i,0,N-2) ans = max(ans,arr[i+1] - arr[i]);
                                        
                                      return ans;
    }
    ll mx, ans = 1, x = 0, _;
    ll empty_num = 0;
    MinMax(0,(ll)1e18,&x,&mx);
    ans = (mx - x) / N + 1;
    while (x < mx){
        ll amt = ans, res = -1, y;
        while (res == -1){
            MinMax(x+1,min(mx, x+amt),&res,&y);
            empty_num += (res == -1);
            if (x + amt >= mx) break;
            amt <<= 1;
        }
        if (res == -1) break;
        ans = max(ans, res - x);
        x = y;
    }
    assert(empty_num <= N+70);
    return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:50: error: 'arr' was not declared in this scope
   38 |                                 MinMax(curs,curt,arr + i, arr + N - i - 1);
      |                                                  ^~~
gap.cpp:43:60: error: 'arr' was not declared in this scope
   43 |                                 FOR(i,0,N-2) ans = max(ans,arr[i+1] - arr[i]);
      |                                                            ^~~
gap.cpp:47:28: warning: unused variable '_' [-Wunused-variable]
   47 |     ll mx, ans = 1, x = 0, _;
      |                            ^