Submission #937291

# Submission time Handle Problem Language Result Execution time Memory
937291 2024-03-03T18:48:51 Z snpmrnhlol The Big Prize (IOI17_prize) C++17
97.65 / 100
37 ms 3196 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int K = 500;
const int N = 2e5;
const int L = 5000;
const int mod = 998244353;
set <int> s;
int l2[N],r2[N];
int cnt = 0;
int mx = 0;
int qcount = 0;
int ans = -1;
int seed = 17;
int f(){
    return rng()%mod;
    seed = 1ll*seed*seed%mod;
    return seed;
}
vector<int> ask2(int x){
    if(l2[x] == 0 && r2[x] == 0){
        auto nr = ask(x);
        l2[x] = nr[0];
        r2[x] = nr[1];
    }
    return {l2[x],r2[x]};
}
void solve(int l,int r,int dl,int dr){
    if(dl + dr >= mx)return;
    if(l > r)return;
    int mij = (l + r)/2;
    for(int i = mij;i <= r;i++){
        auto x = ask2(i);
        if(x[0] + x[1] == mx){
            x[0]-=dl;
            x[1]-=dr;
            solve(i + 1,r,x[0] + dl,dr);
            if(ans != -1)return;
            solve(l,mij - 1,dl,dr + x[1] + i - mij);
            return;
        }else{
            if(x[0] + x[1] == 0){
                ans = i;
                return;
            }
        }
    }
    solve(l,mij - 1,dl,dr);
    return;
}
int find_best(int n) {
    for(int i = 0;i < K;i++){
        int id = f()%n;
        //cout<<id<<'\n';
        auto x = ask2(id);
        int nr = x[0] + x[1];
        if(nr == 0)return id;
        if(nr > mx){
            mx = nr;
            cnt = 1;
        }else if(nr == mx){
            cnt++;
        }
    }
    solve(0,n - 1,0,0);
	return ans;
}
/**
8
3 3 3 3 2 2 2 1
**/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2184 KB Output is correct
2 Correct 3 ms 1820 KB Output is correct
3 Correct 3 ms 2052 KB Output is correct
4 Correct 3 ms 2064 KB Output is correct
5 Correct 4 ms 2032 KB Output is correct
6 Correct 3 ms 2320 KB Output is correct
7 Correct 3 ms 1868 KB Output is correct
8 Correct 4 ms 2264 KB Output is correct
9 Correct 3 ms 2328 KB Output is correct
10 Correct 4 ms 1724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1880 KB Output is correct
2 Correct 3 ms 1824 KB Output is correct
3 Correct 4 ms 1728 KB Output is correct
4 Correct 3 ms 2072 KB Output is correct
5 Correct 3 ms 1840 KB Output is correct
6 Correct 3 ms 1796 KB Output is correct
7 Correct 3 ms 1884 KB Output is correct
8 Correct 3 ms 1860 KB Output is correct
9 Correct 4 ms 2200 KB Output is correct
10 Correct 3 ms 2244 KB Output is correct
11 Correct 4 ms 3012 KB Output is correct
12 Correct 7 ms 2384 KB Output is correct
13 Correct 4 ms 2704 KB Output is correct
14 Correct 5 ms 456 KB Output is correct
15 Correct 30 ms 2088 KB Output is correct
16 Correct 6 ms 1804 KB Output is correct
17 Correct 24 ms 2464 KB Output is correct
18 Correct 3 ms 2020 KB Output is correct
19 Correct 21 ms 2436 KB Output is correct
20 Correct 10 ms 1416 KB Output is correct
21 Correct 18 ms 2440 KB Output is correct
22 Correct 20 ms 2692 KB Output is correct
23 Correct 6 ms 2708 KB Output is correct
24 Correct 5 ms 2552 KB Output is correct
25 Correct 11 ms 2404 KB Output is correct
26 Correct 10 ms 2232 KB Output is correct
27 Correct 3 ms 2304 KB Output is correct
28 Correct 4 ms 2428 KB Output is correct
29 Correct 5 ms 1988 KB Output is correct
30 Correct 3 ms 2076 KB Output is correct
31 Correct 25 ms 2180 KB Output is correct
32 Correct 4 ms 2348 KB Output is correct
33 Correct 1 ms 448 KB Output is correct
34 Correct 15 ms 2408 KB Output is correct
35 Correct 4 ms 1696 KB Output is correct
36 Correct 16 ms 2440 KB Output is correct
37 Correct 4 ms 2156 KB Output is correct
38 Correct 3 ms 2324 KB Output is correct
39 Correct 11 ms 2344 KB Output is correct
40 Correct 4 ms 1876 KB Output is correct
41 Correct 15 ms 1884 KB Output is correct
42 Correct 13 ms 2060 KB Output is correct
43 Correct 12 ms 2528 KB Output is correct
44 Correct 15 ms 2156 KB Output is correct
45 Correct 18 ms 2332 KB Output is correct
46 Correct 26 ms 2636 KB Output is correct
47 Correct 13 ms 2608 KB Output is correct
48 Correct 8 ms 2220 KB Output is correct
49 Correct 23 ms 2448 KB Output is correct
50 Correct 3 ms 2260 KB Output is correct
51 Correct 19 ms 2452 KB Output is correct
52 Correct 22 ms 2468 KB Output is correct
53 Correct 3 ms 2132 KB Output is correct
54 Correct 16 ms 2848 KB Output is correct
55 Correct 24 ms 2168 KB Output is correct
56 Correct 4 ms 2240 KB Output is correct
57 Correct 12 ms 2408 KB Output is correct
58 Correct 8 ms 2292 KB Output is correct
59 Correct 13 ms 2552 KB Output is correct
60 Correct 12 ms 2392 KB Output is correct
61 Correct 3 ms 2140 KB Output is correct
62 Correct 4 ms 2592 KB Output is correct
63 Correct 3 ms 2016 KB Output is correct
64 Correct 3 ms 2100 KB Output is correct
65 Correct 3 ms 2000 KB Output is correct
66 Correct 6 ms 2356 KB Output is correct
67 Correct 4 ms 2040 KB Output is correct
68 Correct 3 ms 1856 KB Output is correct
69 Correct 4 ms 1928 KB Output is correct
70 Correct 4 ms 1808 KB Output is correct
71 Partially correct 23 ms 2132 KB Partially correct - number of queries: 5235
72 Correct 5 ms 2964 KB Output is correct
73 Partially correct 37 ms 2412 KB Partially correct - number of queries: 5173
74 Partially correct 24 ms 2200 KB Partially correct - number of queries: 5195
75 Correct 4 ms 1900 KB Output is correct
76 Correct 22 ms 2940 KB Output is correct
77 Correct 30 ms 2756 KB Output is correct
78 Correct 7 ms 2500 KB Output is correct
79 Correct 13 ms 2828 KB Output is correct
80 Correct 22 ms 2748 KB Output is correct
81 Correct 29 ms 2644 KB Output is correct
82 Correct 23 ms 3196 KB Output is correct
83 Correct 3 ms 2240 KB Output is correct
84 Correct 23 ms 2500 KB Output is correct
85 Correct 20 ms 2960 KB Output is correct
86 Correct 16 ms 2944 KB Output is correct
87 Correct 5 ms 2664 KB Output is correct
88 Correct 14 ms 2616 KB Output is correct
89 Correct 12 ms 2756 KB Output is correct
90 Correct 3 ms 1992 KB Output is correct
91 Correct 8 ms 2040 KB Output is correct
92 Correct 10 ms 2200 KB Output is correct
93 Correct 23 ms 2612 KB Output is correct
94 Correct 15 ms 1920 KB Output is correct
95 Correct 20 ms 2216 KB Output is correct
96 Correct 22 ms 2392 KB Output is correct
97 Correct 4 ms 1896 KB Output is correct