Submission #624458

#TimeUsernameProblemLanguageResultExecution timeMemory
624458socpiteGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;

#define f first
#define s second

typedef long long ll;

ll ans = 0;

int n;

bool cmp(pair<ll, ll> a, pair<ll, ll> b)return b.f-a.f < b.s - a.s;

void solve(ll l, ll r, ll ele){
    if(r-l <= ans)return;
    ll dist;
    if(ele >= 5)dist = min((r-l+ele*2)/ele*2, r-l-1);
    else dist = (r-l+ele)/ele;
    vector<pair<ll, ll>> A;
    for(ll i = l;  i <= r; i+=dist){
        pair<ll, ll> tmp;
        MinMax(i, min(i+dist-1, r), &tmp.f, &tmp.s);
        if(tmp.s > 0){
            ele -= 1+(tmp.f != tmp.s);
            A.push_back(tmp);
        }
    }
    for(int i = 1; i < A.size(); i++){
        if(A[i-1].f != -1 && A[i].f != -1)ans = max(ans, A[i].f - A[i-1].s);
    }
    sort(A.begin(), A.end(), cmp);
    for(auto v: A)solve(v.f, v.s, ele+1+(v.f != v.s));
}

long long findGap(int T, int N)
{
    n = N;
    solve(0, 1e18, N);
    return ans;
}

Compilation message (stderr)

gap.cpp: In function 'bool cmp(std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
gap.cpp:14:41: error: named return values are no longer supported
   14 | bool cmp(pair<ll, ll> a, pair<ll, ll> b)return b.f-a.f < b.s - a.s;
      |                                         ^~~~~~
gap.cpp:17:8: error: 'r' was not declared in this scope
   17 |     if(r-l <= ans)return;
      |        ^
gap.cpp:17:10: error: 'l' was not declared in this scope
   17 |     if(r-l <= ans)return;
      |          ^
gap.cpp:17:19: error: return-statement with no value, in function returning 'bool' [-fpermissive]
   17 |     if(r-l <= ans)return;
      |                   ^~~~~~
gap.cpp:19:8: error: 'ele' was not declared in this scope
   19 |     if(ele >= 5)dist = min((r-l+ele*2)/ele*2, r-l-1);
      |        ^~~
gap.cpp:19:29: error: 'r' was not declared in this scope
   19 |     if(ele >= 5)dist = min((r-l+ele*2)/ele*2, r-l-1);
      |                             ^
gap.cpp:19:31: error: 'l' was not declared in this scope
   19 |     if(ele >= 5)dist = min((r-l+ele*2)/ele*2, r-l-1);
      |                               ^
gap.cpp:20:18: error: 'r' was not declared in this scope
   20 |     else dist = (r-l+ele)/ele;
      |                  ^
gap.cpp:20:20: error: 'l' was not declared in this scope
   20 |     else dist = (r-l+ele)/ele;
      |                    ^
gap.cpp:22:16: error: 'l' was not declared in this scope
   22 |     for(ll i = l;  i <= r; i+=dist){
      |                ^
gap.cpp:22:25: error: 'r' was not declared in this scope
   22 |     for(ll i = l;  i <= r; i+=dist){
      |                         ^
gap.cpp:26:13: error: 'ele' was not declared in this scope
   26 |             ele -= 1+(tmp.f != tmp.s);
      |             ^~~
gap.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i = 1; i < A.size(); i++){
      |                    ~~^~~~~~~~~~
gap.cpp:34:35: error: 'ele' was not declared in this scope
   34 |     for(auto v: A)solve(v.f, v.s, ele+1+(v.f != v.s));
      |                                   ^~~
gap.cpp:34:19: error: 'solve' was not declared in this scope
   34 |     for(auto v: A)solve(v.f, v.s, ele+1+(v.f != v.s));
      |                   ^~~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:40:5: error: 'solve' was not declared in this scope
   40 |     solve(0, 1e18, N);
      |     ^~~~~