Submission #301346

# Submission time Handle Problem Language Result Execution time Memory
301346 2020-09-17T21:06:57 Z toloraia The Big Prize (IOI17_prize) C++14
100 / 100
143 ms 3740 KB
// 12:10
#include "prize.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
//#define int long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")

#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")

#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const int N = 200005;

int a[N], b[N], F[N];


void mak (int x){
    if (F[x])
        return;
    vector < int > res = ask (x);
    a[x] = res[0];
    b[x] = res[1];
    F[x] = 1;
}
int m;

vector < int > solve (int l, int r, int L, int R){
    vector < int > ans;
    if (l > r || L > R)
        return ans;
    int mid = l + r >> 1;
    while (mid >= l){
        mak (mid);
        if (a[mid] + b[mid] == m)
            break;
        ans.pb (mid);
        mid--;
    }
    int le = mid-1;
    int ri = (l+r>>1)+1;
    int LL = L-1;
    if (mid >= l)
        LL = a[mid];
    int RR = LL + 1 + (int)ans.size();
    vector < int > A = solve (l, le, L, LL);
    vector < int > B = solve (ri, r, RR, R);
    for (int x : A)
        ans.pb (x);
    for (int x : B)
        ans.pb (x);
    return ans;
}

int find_best(int n) {
    m = min (n-1, 446);
    vector < int > V;
    for (int i = 0; i < n; i++)
        V.pb (i);
    for (int i = 0; i < 20; i++)
        random_shuffle(V.begin(), V.end());
    int nn = 0;
    for (int i, x = 0; x <= m; x++){
        i = V[x];
        mak (i);
        nn = max (nn, a[i] + b[i]);
        if (nn > 30)
            break;
    }
    m = nn;
    vector < int > ans = solve (0, n-1, 1, m);
    for (int x : ans){
        mak (x);
        if (a[x] + b[x] == 0)
            return x;
    }
}

Compilation message

prize.cpp:21:1: warning: "/*" within comment [-Wcomment]
   21 | /*
      |  
prize.cpp: In function 'std::vector<int> solve(int, int, int, int)':
prize.cpp:54:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   54 |     int mid = l + r >> 1;
      |               ~~^~~
prize.cpp:63:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   63 |     int ri = (l+r>>1)+1;
      |               ~^~
prize.cpp: In function 'int find_best(int)':
prize.cpp:79:20: warning: control reaches end of non-void function [-Wreturn-type]
   79 |     vector < int > V;
      |                    ^
# Verdict Execution time Memory Grader output
1 Correct 92 ms 3304 KB Output is correct
2 Correct 85 ms 3364 KB Output is correct
3 Correct 79 ms 3436 KB Output is correct
4 Correct 81 ms 3308 KB Output is correct
5 Correct 79 ms 3396 KB Output is correct
6 Correct 79 ms 3304 KB Output is correct
7 Correct 80 ms 3436 KB Output is correct
8 Correct 80 ms 3432 KB Output is correct
9 Correct 76 ms 3408 KB Output is correct
10 Correct 80 ms 3436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 90 ms 3564 KB Output is correct
2 Correct 80 ms 3436 KB Output is correct
3 Correct 81 ms 3432 KB Output is correct
4 Correct 79 ms 3308 KB Output is correct
5 Correct 79 ms 3408 KB Output is correct
6 Correct 78 ms 3304 KB Output is correct
7 Correct 81 ms 3436 KB Output is correct
8 Correct 79 ms 3308 KB Output is correct
9 Correct 82 ms 3404 KB Output is correct
10 Correct 79 ms 3308 KB Output is correct
11 Correct 80 ms 2576 KB Output is correct
12 Correct 84 ms 2580 KB Output is correct
13 Correct 79 ms 2572 KB Output is correct
14 Correct 17 ms 768 KB Output is correct
15 Correct 112 ms 3564 KB Output is correct
16 Correct 107 ms 3568 KB Output is correct
17 Correct 113 ms 3560 KB Output is correct
18 Correct 117 ms 3560 KB Output is correct
19 Correct 113 ms 3688 KB Output is correct
20 Correct 69 ms 2160 KB Output is correct
21 Correct 113 ms 3564 KB Output is correct
22 Correct 104 ms 3692 KB Output is correct
23 Correct 82 ms 3436 KB Output is correct
24 Correct 81 ms 2424 KB Output is correct
25 Correct 119 ms 3592 KB Output is correct
26 Correct 108 ms 3688 KB Output is correct
27 Correct 84 ms 3432 KB Output is correct
28 Correct 108 ms 3564 KB Output is correct
29 Correct 112 ms 3560 KB Output is correct
30 Correct 132 ms 3560 KB Output is correct
31 Correct 108 ms 3620 KB Output is correct
32 Correct 82 ms 2664 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 111 ms 3608 KB Output is correct
35 Correct 84 ms 3600 KB Output is correct
36 Correct 119 ms 3600 KB Output is correct
37 Correct 77 ms 2280 KB Output is correct
38 Correct 81 ms 3436 KB Output is correct
39 Correct 126 ms 3560 KB Output is correct
40 Correct 105 ms 3560 KB Output is correct
41 Correct 102 ms 3628 KB Output is correct
42 Correct 118 ms 3600 KB Output is correct
43 Correct 116 ms 3560 KB Output is correct
44 Correct 116 ms 3692 KB Output is correct
45 Correct 112 ms 3692 KB Output is correct
46 Correct 127 ms 3564 KB Output is correct
47 Correct 114 ms 3560 KB Output is correct
48 Correct 132 ms 3688 KB Output is correct
49 Correct 125 ms 3564 KB Output is correct
50 Correct 120 ms 3652 KB Output is correct
51 Correct 128 ms 3552 KB Output is correct
52 Correct 111 ms 3560 KB Output is correct
53 Correct 82 ms 3432 KB Output is correct
54 Correct 112 ms 3564 KB Output is correct
55 Correct 109 ms 3692 KB Output is correct
56 Correct 108 ms 3560 KB Output is correct
57 Correct 106 ms 3564 KB Output is correct
58 Correct 126 ms 3560 KB Output is correct
59 Correct 130 ms 3564 KB Output is correct
60 Correct 118 ms 3564 KB Output is correct
61 Correct 94 ms 3476 KB Output is correct
62 Correct 82 ms 3436 KB Output is correct
63 Correct 82 ms 3432 KB Output is correct
64 Correct 82 ms 3432 KB Output is correct
65 Correct 74 ms 1520 KB Output is correct
66 Correct 79 ms 1528 KB Output is correct
67 Correct 80 ms 1528 KB Output is correct
68 Correct 78 ms 1528 KB Output is correct
69 Correct 79 ms 1528 KB Output is correct
70 Correct 77 ms 1528 KB Output is correct
71 Correct 118 ms 3564 KB Output is correct
72 Correct 77 ms 2664 KB Output is correct
73 Correct 133 ms 3688 KB Output is correct
74 Correct 130 ms 3560 KB Output is correct
75 Correct 80 ms 3440 KB Output is correct
76 Correct 105 ms 3560 KB Output is correct
77 Correct 116 ms 3692 KB Output is correct
78 Correct 79 ms 2668 KB Output is correct
79 Correct 85 ms 3620 KB Output is correct
80 Correct 124 ms 3740 KB Output is correct
81 Correct 106 ms 3580 KB Output is correct
82 Correct 129 ms 3560 KB Output is correct
83 Correct 99 ms 3492 KB Output is correct
84 Correct 121 ms 3560 KB Output is correct
85 Correct 126 ms 3560 KB Output is correct
86 Correct 86 ms 3052 KB Output is correct
87 Correct 75 ms 1896 KB Output is correct
88 Correct 91 ms 3052 KB Output is correct
89 Correct 88 ms 3132 KB Output is correct
90 Correct 84 ms 3436 KB Output is correct
91 Correct 85 ms 3052 KB Output is correct
92 Correct 95 ms 3064 KB Output is correct
93 Correct 143 ms 3600 KB Output is correct
94 Correct 116 ms 3600 KB Output is correct
95 Correct 133 ms 3560 KB Output is correct
96 Correct 115 ms 3584 KB Output is correct
97 Correct 124 ms 3560 KB Output is correct