답안 #897127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
897127 2024-01-02T15:13:28 Z raul2008487 Gap (APIO16_gap) C++17
12.6461 / 100
37 ms 4212 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<n; 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: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;
      |                  ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Incorrect 0 ms 2392 KB Output isn't 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 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2656 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 2 ms 2488 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 9 ms 2836 KB Output is correct
17 Correct 8 ms 2840 KB Output is correct
18 Correct 9 ms 2824 KB Output is correct
19 Correct 9 ms 2840 KB Output is correct
20 Correct 7 ms 2904 KB Output is correct
21 Correct 32 ms 4000 KB Output is correct
22 Correct 36 ms 4212 KB Output is correct
23 Correct 37 ms 3988 KB Output is correct
24 Correct 32 ms 4156 KB Output is correct
25 Correct 29 ms 3996 KB Output is correct
26 Correct 32 ms 3988 KB Output is correct
27 Correct 32 ms 4112 KB Output is correct
28 Correct 33 ms 4036 KB Output is correct
29 Correct 32 ms 4136 KB Output is correct
30 Correct 26 ms 3984 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 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 0 ms 2392 KB Partially correct
5 Partially correct 0 ms 2392 KB Partially correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 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 2656 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 2584 KB Output is correct
17 Correct 5 ms 2580 KB Output is correct
18 Correct 5 ms 2576 KB Output is correct
19 Correct 5 ms 2840 KB Output is correct
20 Correct 4 ms 2572 KB Output is correct
21 Correct 17 ms 2836 KB Output is correct
22 Correct 18 ms 2992 KB Output is correct
23 Correct 17 ms 2848 KB Output is correct
24 Correct 17 ms 3000 KB Output is correct
25 Partially correct 37 ms 2852 KB Partially correct
26 Correct 19 ms 2944 KB Output is correct
27 Correct 26 ms 2852 KB Output is correct
28 Correct 18 ms 2936 KB Output is correct
29 Correct 17 ms 3016 KB Output is correct
30 Correct 17 ms 2860 KB Output is correct
31 Partially correct 1 ms 2392 KB Partially correct
32 Correct 0 ms 2392 KB Output is correct