Submission #560979

# Submission time Handle Problem Language Result Execution time Memory
560979 2022-05-12T06:34:25 Z Huy Gap (APIO16_gap) C++17
100 / 100
59 ms 1872 KB
#include "gap.h"
#include<bits/stdc++.h>
//#define int long long
#define pii pair<int,int>
#define fi first
#define se second
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")*/
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ldb = long double;
const int N = (int)5e5;
const int maxN = (int)5e5 + 5;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infty = 1e18;
const ll logn = 18;
const int base = 311;
const int Block_size = 500;
const int ep = 'a';

int cu[] = {0,0,1,-1};
int cv[] = {-1,1,0,0};

int du[] = {-1,-1,+1,1};
int dv[] = {-1,+1,-1,1};

int cled[] = {6,2,5,5,4,5,6,3,7,6};

void InputFile()
{
    freopen(".inp","r",stdin);
    freopen(".out","w",stdout);
    //freopen("test.out","r",stdin);
}

void FastInput()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

/*void MinMax(int L,int R,int x,int y)
{
    return;
}*/
ll a[maxN];
ll findGap(int T, int n)
{
    if(T == 1)
    {
        ll l = 0, r = 1e18, a[n + 1];
        for (int i = 1; i <= n && (n - i + 1) >= i; i++)
        {
            MinMax(l, r, &a[i], &a[n - i + 1]);
            l = a[i] + 1;
            r = a[n - i + 1] - 1;
        }
        ll ans = 0;
        for (int i = 2; i <= n; i++)
        {
            ans = max(ans, a[i] - a[i - 1]);
        }
        return ans;
    }
    ll res = 0;
    ll mini,maxi;
    MinMax(0,infty, &mini, &maxi);
    ll pre = mini;
    ll h = (maxi - mini + n - 2) / (n - 1);
    ll now = mini + 1;
    while(true)
    {
        ll p, q;
        MinMax(now, now + h - 1, &p, &q);
        res = max(res, p - pre);
        pre = max(pre, q);
        now += h;
        if(q == maxi) break;
    }
    return res;
}

/*void Read()
{

}

void Solve()
{

}

void Debug()
{
    //Main_sub();
    //Naive();
}


signed main()
{
    FastInput();
    //InputFile();
    //int sub_type;
    //cin >> sub_type;
    //Sieve();
    int test;
    //cin >> test;
    test = 1;
    while(test--)
        //for(int prc = 1; prc <= test; prc++)
    {
        Read();
        Solve();
        //Debug();
    }
}*/

Compilation message

gap.cpp: In function 'void InputFile()':
gap.cpp:36:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     freopen(".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~
gap.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     freopen(".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 10 ms 592 KB Output is correct
17 Correct 10 ms 720 KB Output is correct
18 Correct 12 ms 684 KB Output is correct
19 Correct 11 ms 592 KB Output is correct
20 Correct 10 ms 720 KB Output is correct
21 Correct 40 ms 1768 KB Output is correct
22 Correct 38 ms 1872 KB Output is correct
23 Correct 45 ms 1820 KB Output is correct
24 Correct 51 ms 1864 KB Output is correct
25 Correct 36 ms 1820 KB Output is correct
26 Correct 37 ms 1828 KB Output is correct
27 Correct 38 ms 1816 KB Output is correct
28 Correct 42 ms 1792 KB Output is correct
29 Correct 44 ms 1812 KB Output is correct
30 Correct 33 ms 1868 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 14 ms 464 KB Output is correct
17 Correct 13 ms 464 KB Output is correct
18 Correct 13 ms 524 KB Output is correct
19 Correct 13 ms 464 KB Output is correct
20 Correct 7 ms 440 KB Output is correct
21 Correct 59 ms 1092 KB Output is correct
22 Correct 51 ms 1060 KB Output is correct
23 Correct 54 ms 1056 KB Output is correct
24 Correct 54 ms 1064 KB Output is correct
25 Correct 51 ms 1004 KB Output is correct
26 Correct 59 ms 1172 KB Output is correct
27 Correct 52 ms 1088 KB Output is correct
28 Correct 54 ms 1064 KB Output is correct
29 Correct 55 ms 1056 KB Output is correct
30 Correct 30 ms 1016 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct