Submission #713061

# Submission time Handle Problem Language Result Execution time Memory
713061 2023-03-21T02:30:17 Z lam The Big Prize (IOI17_prize) C++14
90 / 100
107 ms 1440 KB
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define ff first
#define ss second
const int maxn = 2e5 + 10;
int n;
int ans;
int rt; ii bound;
int f[maxn];
bool dau[maxn];
//vector <int> ask(int x)
//{
//    cout<<x<<endl;
//    int l,r; cin>>l>>r;
//    return {l,r};
//}
void update(int x, int val)
{
    x++;
    while (x<=n)
    {
        f[x]+=val;
        x+=(x&-x);
    }
}
int get(int x)
{
    x++;
    int temp=0;
    while (x>0)
    {
        temp+=f[x];
        x-=(x&-x);
    }
    return temp;
}
int find_best(int N)
{
    n=N;
    int it = min(n,474);
    rt=-1;
    for (int i=0; i<it; i++)
    {
        vector <int> tmp = ask(i);
        int sum = tmp[0] + tmp[1];
        if (sum==0) return i;
        if (rt==-1||bound.ff+bound.ss<sum)
        {
            rt = i;
            bound.ff = tmp[0]; bound.ss = tmp[1];
        }
    }
    fill_n(f,n+1,0);
    for (int i=0; i<bound.ss; i++)
    {
        int l=rt+1; int r=n-1;
        int j = -1;
        int val;
        while (l<=r)
        {
            int mid=(l+r)/2;
            vector <int> tmp = ask(mid);
            if (dau[mid])
            {
                l=mid+1;
                continue;
            }
            if (tmp[0] + tmp[1] != bound.ff + bound.ss || tmp[0] - get(mid) != bound.ff)
            {
                j = mid;
                val = tmp[0] + tmp[1];
                r=mid-1;
            }
            else l=mid+1;
        }
        dau[j]=1;
//        cout<<j<<" :: "<<val<<endl;
        update(j,1);
        if (val==0) return j;
    }
}

//signed main()
//{
//    int n; cin>>n;
//    cout<<find_best(n)<<"!!"<<endl;
//}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:84:1: warning: control reaches end of non-void function [-Wreturn-type]
   84 | }
      | ^
prize.cpp:82:9: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
   82 |         if (val==0) return j;
      |         ^~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 976 KB Output is correct
2 Correct 5 ms 1056 KB Output is correct
3 Correct 3 ms 1072 KB Output is correct
4 Correct 4 ms 968 KB Output is correct
5 Correct 4 ms 1068 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 3 ms 1072 KB Output is correct
8 Correct 7 ms 1064 KB Output is correct
9 Correct 7 ms 1068 KB Output is correct
10 Correct 5 ms 1072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1072 KB Output is correct
2 Correct 3 ms 1060 KB Output is correct
3 Correct 7 ms 968 KB Output is correct
4 Correct 5 ms 1048 KB Output is correct
5 Correct 3 ms 1056 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 4 ms 1076 KB Output is correct
8 Correct 5 ms 1048 KB Output is correct
9 Correct 3 ms 976 KB Output is correct
10 Correct 7 ms 1072 KB Output is correct
11 Correct 8 ms 1068 KB Output is correct
12 Correct 4 ms 1112 KB Output is correct
13 Correct 11 ms 1108 KB Output is correct
14 Correct 10 ms 336 KB Output is correct
15 Correct 15 ms 1092 KB Output is correct
16 Partially correct 73 ms 1096 KB Partially correct - number of queries: 7392
17 Correct 2 ms 208 KB Output is correct
18 Partially correct 95 ms 1228 KB Partially correct - number of queries: 8827
19 Correct 5 ms 300 KB Output is correct
20 Correct 24 ms 704 KB Output is correct
21 Correct 48 ms 1068 KB Output is correct
22 Correct 8 ms 976 KB Output is correct
23 Correct 4 ms 968 KB Output is correct
24 Correct 5 ms 968 KB Output is correct
25 Partially correct 47 ms 1076 KB Partially correct - number of queries: 5001
26 Correct 61 ms 1144 KB Output is correct
27 Correct 5 ms 976 KB Output is correct
28 Partially correct 76 ms 1440 KB Partially correct - number of queries: 8368
29 Partially correct 46 ms 1216 KB Partially correct - number of queries: 6344
30 Partially correct 37 ms 1264 KB Partially correct - number of queries: 8751
31 Correct 5 ms 208 KB Output is correct
32 Correct 7 ms 1068 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Correct 28 ms 1072 KB Output is correct
35 Correct 5 ms 1060 KB Output is correct
36 Correct 20 ms 1088 KB Output is correct
37 Correct 6 ms 1068 KB Output is correct
38 Correct 5 ms 1068 KB Output is correct
39 Correct 21 ms 1244 KB Output is correct
40 Partially correct 30 ms 1376 KB Partially correct - number of queries: 7564
41 Partially correct 55 ms 1140 KB Partially correct - number of queries: 5225
42 Partially correct 52 ms 1056 KB Partially correct - number of queries: 5225
43 Correct 39 ms 1164 KB Output is correct
44 Correct 39 ms 1068 KB Output is correct
45 Correct 13 ms 1132 KB Output is correct
46 Correct 4 ms 296 KB Output is correct
47 Correct 41 ms 1056 KB Output is correct
48 Partially correct 44 ms 1084 KB Partially correct - number of queries: 6415
49 Correct 6 ms 1084 KB Output is correct
50 Partially correct 87 ms 1204 KB Partially correct - number of queries: 8832
51 Correct 31 ms 1224 KB Output is correct
52 Correct 4 ms 1076 KB Output is correct
53 Correct 4 ms 1072 KB Output is correct
54 Correct 22 ms 1156 KB Output is correct
55 Correct 7 ms 300 KB Output is correct
56 Partially correct 75 ms 1336 KB Partially correct - number of queries: 8815
57 Partially correct 63 ms 1184 KB Partially correct - number of queries: 6336
58 Partially correct 58 ms 1192 KB Partially correct - number of queries: 6418
59 Partially correct 42 ms 1096 KB Partially correct - number of queries: 5242
60 Correct 40 ms 1096 KB Output is correct
61 Correct 6 ms 1096 KB Output is correct
62 Correct 3 ms 1076 KB Output is correct
63 Correct 6 ms 1072 KB Output is correct
64 Correct 5 ms 976 KB Output is correct
65 Correct 7 ms 1056 KB Output is correct
66 Partially correct 69 ms 968 KB Partially correct - number of queries: 8753
67 Correct 6 ms 1060 KB Output is correct
68 Correct 4 ms 208 KB Output is correct
69 Partially correct 100 ms 1064 KB Partially correct - number of queries: 8453
70 Correct 7 ms 1060 KB Output is correct
71 Partially correct 107 ms 1204 KB Partially correct - number of queries: 8970
72 Correct 9 ms 1104 KB Output is correct
73 Partially correct 86 ms 1244 KB Partially correct - number of queries: 8844
74 Partially correct 79 ms 1212 KB Partially correct - number of queries: 8898
75 Correct 8 ms 1080 KB Output is correct
76 Partially correct 67 ms 1148 KB Partially correct - number of queries: 7674
77 Partially correct 70 ms 1220 KB Partially correct - number of queries: 8970
78 Correct 11 ms 1204 KB Output is correct
79 Correct 40 ms 1200 KB Output is correct
80 Partially correct 50 ms 1324 KB Partially correct - number of queries: 8970
81 Partially correct 80 ms 1208 KB Partially correct - number of queries: 8970
82 Partially correct 85 ms 1256 KB Partially correct - number of queries: 8896
83 Correct 4 ms 1104 KB Output is correct
84 Partially correct 85 ms 1212 KB Partially correct - number of queries: 7386
85 Partially correct 83 ms 1352 KB Partially correct - number of queries: 8969
86 Correct 5 ms 976 KB Output is correct
87 Correct 5 ms 1080 KB Output is correct
88 Correct 3 ms 976 KB Output is correct
89 Correct 6 ms 976 KB Output is correct
90 Correct 5 ms 976 KB Output is correct
91 Correct 3 ms 1072 KB Output is correct
92 Correct 4 ms 976 KB Output is correct
93 Correct 9 ms 1104 KB Output is correct
94 Correct 8 ms 1180 KB Output is correct
95 Correct 9 ms 1104 KB Output is correct
96 Correct 7 ms 1108 KB Output is correct
97 Correct 5 ms 1104 KB Output is correct