Submission #897150

# Submission time Handle Problem Language Result Execution time Memory
897150 2024-01-02T15:50:50 Z raul2008487 Gap (APIO16_gap) C++17
30 / 100
34 ms 4228 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 2644 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 1 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 3008 KB Output is correct
17 Correct 8 ms 3008 KB Output is correct
18 Correct 12 ms 2912 KB Output is correct
19 Correct 8 ms 2836 KB Output is correct
20 Correct 8 ms 2904 KB Output is correct
21 Correct 32 ms 3876 KB Output is correct
22 Correct 33 ms 3792 KB Output is correct
23 Correct 32 ms 4000 KB Output is correct
24 Correct 34 ms 4228 KB Output is correct
25 Correct 28 ms 3992 KB Output is correct
26 Correct 32 ms 4000 KB Output is correct
27 Correct 32 ms 3988 KB Output is correct
28 Correct 32 ms 3992 KB Output is correct
29 Correct 31 ms 4000 KB Output is correct
30 Correct 29 ms 3988 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 2392 KB Partially correct
2 Incorrect 0 ms 2392 KB Output isn't correct
3 Incorrect 0 ms 2392 KB Output isn't correct
4 Partially correct 1 ms 2392 KB Partially correct
5 Partially correct 1 ms 2392 KB Partially correct
6 Incorrect 0 ms 2392 KB Output isn't correct
7 Correct 0 ms 2392 KB Output is correct
8 Incorrect 0 ms 2392 KB Output isn't correct
9 Incorrect 1 ms 2392 KB Output isn't correct
10 Correct 0 ms 2392 KB Output is correct
11 Incorrect 1 ms 2392 KB Output isn't correct
12 Incorrect 1 ms 2392 KB Output isn't correct
13 Incorrect 1 ms 2392 KB Output isn't correct
14 Incorrect 1 ms 2392 KB Output isn't correct
15 Correct 1 ms 2392 KB Output is correct
16 Incorrect 3 ms 2752 KB Output isn't correct
17 Incorrect 3 ms 2588 KB Output isn't correct
18 Incorrect 3 ms 2592 KB Output isn't correct
19 Incorrect 4 ms 2588 KB Output isn't correct
20 Correct 3 ms 2836 KB Output is correct
21 Incorrect 12 ms 2856 KB Output isn't correct
22 Incorrect 12 ms 2852 KB Output isn't correct
23 Incorrect 13 ms 2852 KB Output isn't correct
24 Incorrect 12 ms 2856 KB Output isn't correct
25 Correct 9 ms 2852 KB Output is correct
26 Incorrect 12 ms 2892 KB Output isn't correct
27 Incorrect 12 ms 2860 KB Output isn't correct
28 Incorrect 12 ms 2856 KB Output isn't correct
29 Incorrect 13 ms 2784 KB Output isn't correct
30 Correct 10 ms 2848 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct