Submission #897128

# Submission time Handle Problem Language Result Execution time Memory
897128 2024-01-02T15:14:00 Z raul2008487 Gap (APIO16_gap) C++17
42.6461 / 100
36 ms 4032 KB
#include<bits/stdc++.h>
#include "gap.h"
#define ll long long
#define pll pair<ll,ll>
#define vl vector<ll>
#define pb push_back
#define in insert
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
long long findGap(int T, int N)
{
    ll l, r, i, j, lo = 1, hi = 1000000000000000000, ans = 0, n = N;
    MinMax(lo, hi, &l, &r);
    if( T == 1 ){
        vl v;
        v.pb(l);
        v.pb(r);
        while(l != r && v.size() < n){
            lo = l + 1, hi = r - 1;
            MinMax(lo, hi, &l, &r);
            v.pb(l);
            v.pb(r);
        }
        sort(all(v));
        for(i = 1; i<v.size(); i++){
            ans = max(ans, (v[i] - v[i-1]));
        }
        return ans;
    }
    ll a, b, d1, d2, pw = 1;
    while(l != r){
        a = b = -1;
        while(a == -1){MinMax(l + 1, l + 1 + pw, &a, &b); pw <<= 1;}
        ans = max(ans, (a - l));
        pw = ans;
        l = b;
    }
    return ans;

}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:21:34: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   21 |         while(l != r && v.size() < n){
      |                         ~~~~~~~~~^~~
gap.cpp:28:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(i = 1; i<v.size(); i++){
      |                    ~^~~~~~~~~
gap.cpp:15:17: warning: unused variable 'j' [-Wunused-variable]
   15 |     ll l, r, i, j, lo = 1, hi = 1000000000000000000, ans = 0, n = N;
      |                 ^
gap.cpp:33:14: warning: unused variable 'd1' [-Wunused-variable]
   33 |     ll a, b, d1, d2, pw = 1;
      |              ^~
gap.cpp:33:18: warning: unused variable 'd2' [-Wunused-variable]
   33 |     ll a, b, d1, d2, pw = 1;
      |                  ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 0 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 8 ms 3080 KB Output is correct
17 Correct 10 ms 3100 KB Output is correct
18 Correct 8 ms 2832 KB Output is correct
19 Correct 8 ms 3072 KB Output is correct
20 Correct 7 ms 2828 KB Output is correct
21 Correct 31 ms 3800 KB Output is correct
22 Correct 32 ms 3928 KB Output is correct
23 Correct 33 ms 4032 KB Output is correct
24 Correct 35 ms 4004 KB Output is correct
25 Correct 28 ms 3992 KB Output is correct
26 Correct 31 ms 3868 KB Output is correct
27 Correct 32 ms 3992 KB Output is correct
28 Correct 34 ms 4000 KB Output is correct
29 Correct 31 ms 3992 KB Output is correct
30 Correct 26 ms 3996 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 2392 KB Partially correct
2 Partially correct 0 ms 2392 KB Partially correct
3 Partially correct 0 ms 2392 KB Partially correct
4 Partially correct 1 ms 2392 KB Partially correct
5 Partially correct 1 ms 2392 KB Partially correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Partially correct 1 ms 2392 KB Partially correct
16 Correct 5 ms 2592 KB Output is correct
17 Correct 5 ms 2752 KB Output is correct
18 Correct 5 ms 2588 KB Output is correct
19 Correct 5 ms 2756 KB Output is correct
20 Correct 3 ms 2580 KB Output is correct
21 Correct 17 ms 2860 KB Output is correct
22 Correct 17 ms 2852 KB Output is correct
23 Correct 17 ms 3020 KB Output is correct
24 Correct 21 ms 2872 KB Output is correct
25 Partially correct 36 ms 2852 KB Partially correct
26 Correct 18 ms 2856 KB Output is correct
27 Correct 17 ms 2856 KB Output is correct
28 Correct 17 ms 2852 KB Output is correct
29 Correct 20 ms 2864 KB Output is correct
30 Correct 13 ms 2872 KB Output is correct
31 Partially correct 1 ms 2644 KB Partially correct
32 Correct 1 ms 2392 KB Output is correct