Submission #659228

# Submission time Handle Problem Language Result Execution time Memory
659228 2022-11-17T06:05:05 Z jiahng The Big Prize (IOI17_prize) C++14
98.79 / 100
68 ms 6208 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 200010
#define INF (ll)1e9
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;
 
int N;
vi memo[maxn];
bool queried[maxn];
int sm[maxn];
vi query(int x){
    if (queried[x]) return memo[x];
    queried[x] = 1;
    memo[x] = ask(x);
    sm[x] = memo[x][0] + memo[x][1];
    return memo[x];
}
bool done = 0;
int dnc(int l,int r){
    if (done || l > r) return -1;
    if (l == r){
        query(l);
        if (sm[l] == 0) return l;
        return -1;
    }

    if (r + 1 < N){
        query(l); query(r+1);
        if (sm[r+1] == sm[l] && memo[l][0] == memo[r+1][0]) return -1;
    }
    int m = (l+r)/2;
    return max(dnc(l,m), dnc(m+1,r));
}
const int sqrtn = 472;
int find_best(int n) {
    N = n;


    int ans = -1;
    FOR(i,0,N/sqrtn) ans = max(ans, dnc(sqrtn*i,min(N-1, sqrtn*(i+1)-1)));
    return ans;
 
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5960 KB Output is correct
2 Correct 7 ms 5892 KB Output is correct
3 Correct 8 ms 5868 KB Output is correct
4 Correct 10 ms 5884 KB Output is correct
5 Correct 7 ms 5960 KB Output is correct
6 Correct 5 ms 6040 KB Output is correct
7 Correct 9 ms 5880 KB Output is correct
8 Correct 5 ms 5968 KB Output is correct
9 Correct 6 ms 5968 KB Output is correct
10 Correct 8 ms 5968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6020 KB Output is correct
2 Correct 6 ms 5968 KB Output is correct
3 Correct 8 ms 5900 KB Output is correct
4 Correct 7 ms 5892 KB Output is correct
5 Correct 7 ms 5888 KB Output is correct
6 Correct 8 ms 5956 KB Output is correct
7 Correct 11 ms 5884 KB Output is correct
8 Correct 7 ms 5968 KB Output is correct
9 Correct 7 ms 5884 KB Output is correct
10 Correct 8 ms 6056 KB Output is correct
11 Correct 10 ms 5892 KB Output is correct
12 Correct 11 ms 5968 KB Output is correct
13 Correct 9 ms 5960 KB Output is correct
14 Correct 13 ms 5048 KB Output is correct
15 Correct 54 ms 6088 KB Output is correct
16 Partially correct 40 ms 6028 KB Partially correct - number of queries: 5025
17 Partially correct 40 ms 6104 KB Partially correct - number of queries: 5095
18 Partially correct 42 ms 6072 KB Partially correct - number of queries: 5070
19 Correct 52 ms 6080 KB Output is correct
20 Correct 34 ms 5524 KB Output is correct
21 Partially correct 44 ms 6084 KB Partially correct - number of queries: 5024
22 Correct 33 ms 5976 KB Output is correct
23 Correct 6 ms 5904 KB Output is correct
24 Correct 9 ms 5884 KB Output is correct
25 Correct 46 ms 6172 KB Output is correct
26 Correct 23 ms 6080 KB Output is correct
27 Correct 6 ms 5956 KB Output is correct
28 Correct 42 ms 6052 KB Output is correct
29 Correct 31 ms 5964 KB Output is correct
30 Partially correct 55 ms 6040 KB Partially correct - number of queries: 5051
31 Partially correct 34 ms 6104 KB Partially correct - number of queries: 5027
32 Correct 13 ms 5884 KB Output is correct
33 Correct 3 ms 4944 KB Output is correct
34 Partially correct 44 ms 6196 KB Partially correct - number of queries: 5040
35 Correct 6 ms 5880 KB Output is correct
36 Partially correct 53 ms 6012 KB Partially correct - number of queries: 5011
37 Correct 13 ms 5880 KB Output is correct
38 Correct 9 ms 5960 KB Output is correct
39 Partially correct 57 ms 6164 KB Partially correct - number of queries: 5026
40 Correct 21 ms 6208 KB Output is correct
41 Partially correct 23 ms 6076 KB Partially correct - number of queries: 5067
42 Partially correct 26 ms 6084 KB Partially correct - number of queries: 5067
43 Correct 51 ms 5980 KB Output is correct
44 Partially correct 46 ms 6180 KB Partially correct - number of queries: 5016
45 Correct 55 ms 5984 KB Output is correct
46 Partially correct 41 ms 5984 KB Partially correct - number of queries: 5036
47 Correct 37 ms 6048 KB Output is correct
48 Partially correct 55 ms 6088 KB Partially correct - number of queries: 5069
49 Partially correct 43 ms 6004 KB Partially correct - number of queries: 5015
50 Partially correct 24 ms 6076 KB Partially correct - number of queries: 5044
51 Partially correct 25 ms 6064 KB Partially correct - number of queries: 5099
52 Partially correct 39 ms 6080 KB Partially correct - number of queries: 5059
53 Correct 7 ms 5968 KB Output is correct
54 Partially correct 68 ms 6056 KB Partially correct - number of queries: 5023
55 Partially correct 52 ms 6008 KB Partially correct - number of queries: 5064
56 Partially correct 43 ms 6052 KB Partially correct - number of queries: 5037
57 Partially correct 44 ms 6008 KB Partially correct - number of queries: 5014
58 Partially correct 49 ms 6036 KB Partially correct - number of queries: 5121
59 Partially correct 36 ms 6000 KB Partially correct - number of queries: 5062
60 Partially correct 47 ms 6112 KB Partially correct - number of queries: 5013
61 Correct 7 ms 5888 KB Output is correct
62 Correct 9 ms 5960 KB Output is correct
63 Correct 6 ms 5900 KB Output is correct
64 Correct 8 ms 5960 KB Output is correct
65 Correct 7 ms 5964 KB Output is correct
66 Correct 10 ms 5888 KB Output is correct
67 Correct 5 ms 5860 KB Output is correct
68 Correct 8 ms 5892 KB Output is correct
69 Correct 5 ms 5860 KB Output is correct
70 Correct 7 ms 5872 KB Output is correct
71 Correct 36 ms 6072 KB Output is correct
72 Correct 9 ms 5988 KB Output is correct
73 Correct 48 ms 6012 KB Output is correct
74 Correct 31 ms 6088 KB Output is correct
75 Correct 7 ms 5968 KB Output is correct
76 Correct 32 ms 5960 KB Output is correct
77 Partially correct 56 ms 6092 KB Partially correct - number of queries: 5049
78 Correct 11 ms 5944 KB Output is correct
79 Correct 27 ms 6036 KB Output is correct
80 Partially correct 53 ms 6048 KB Partially correct - number of queries: 5119
81 Partially correct 39 ms 6000 KB Partially correct - number of queries: 5091
82 Partially correct 42 ms 6056 KB Partially correct - number of queries: 5064
83 Correct 7 ms 5968 KB Output is correct
84 Correct 40 ms 5988 KB Output is correct
85 Partially correct 57 ms 5996 KB Partially correct - number of queries: 5095
86 Correct 11 ms 5876 KB Output is correct
87 Correct 6 ms 5896 KB Output is correct
88 Correct 8 ms 5892 KB Output is correct
89 Correct 11 ms 5904 KB Output is correct
90 Correct 10 ms 5968 KB Output is correct
91 Correct 7 ms 5968 KB Output is correct
92 Correct 8 ms 5904 KB Output is correct
93 Correct 9 ms 5960 KB Output is correct
94 Correct 11 ms 5864 KB Output is correct
95 Correct 10 ms 5956 KB Output is correct
96 Correct 10 ms 5872 KB Output is correct
97 Correct 7 ms 5904 KB Output is correct