답안 #1082715

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1082715 2024-09-01T09:39:51 Z MMihalev 커다란 상품 (IOI17_prize) C++14
97.61 / 100
43 ms 12212 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include "prize.h"
using namespace std;
const int MAX_N=2e5+4;
int asked[MAX_N][2];
bool used[MAX_N];
set<int>kinds;
set<int>idx[MAX_N];
pair<int,int>query(int pos)
{
    if(used[pos])return {asked[pos][0],asked[pos][1]};

    used[pos]=1;
    auto ve=ask(pos);
    asked[pos][0]=ve[0];
    asked[pos][1]=ve[1];
    kinds.insert(ve[0]+ve[1]);
    idx[ve[0]+ve[1]].insert(pos);
    return {ve[0],ve[1]};
}
bool useless(int l,int r)
{
    for(int x:kinds)
    {
        auto it1=idx[x].lower_bound(l);
        auto it2=idx[x].upper_bound(r);
        if(it1!=idx[x].begin() && it2!=idx[x].end())
        {
            it1--;
            int pos1=(*it1);
            int pos2=(*it2);
            if(query(pos2).first-query(pos1).first==0)return 1;
        }
    }
    return 0;
}
int ans=-1;
void rec(int l,int r)
{
    if(l>r)return;
    if(ans!=-1)return;
    int mid=(l+r)/2;
    auto cur=query(mid);
    if(cur.first+cur.second==0){ans=mid;return;}
    if(!useless(l,mid-1))rec(l,mid-1);
    if(!useless(mid+1,r))rec(mid+1,r);
}

int find_best(int n)
{
    int prevpos=-1;
    int qq=480;
    while(qq--)
    {
        prevpos++;
        auto cur=query(prevpos);
        int all=cur.first+cur.second;
        if(all==0)return prevpos;
    }
    prevpos++;
    rec(prevpos,n-1);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9816 KB Output is correct
2 Correct 7 ms 9816 KB Output is correct
3 Correct 6 ms 9816 KB Output is correct
4 Correct 6 ms 9816 KB Output is correct
5 Correct 8 ms 9816 KB Output is correct
6 Correct 5 ms 9816 KB Output is correct
7 Correct 7 ms 9984 KB Output is correct
8 Correct 6 ms 9816 KB Output is correct
9 Correct 7 ms 9816 KB Output is correct
10 Correct 6 ms 9816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9816 KB Output is correct
2 Correct 6 ms 9816 KB Output is correct
3 Correct 7 ms 9816 KB Output is correct
4 Correct 5 ms 9816 KB Output is correct
5 Correct 6 ms 9816 KB Output is correct
6 Correct 4 ms 9816 KB Output is correct
7 Correct 6 ms 9816 KB Output is correct
8 Correct 7 ms 9816 KB Output is correct
9 Correct 7 ms 10072 KB Output is correct
10 Correct 7 ms 9920 KB Output is correct
11 Correct 8 ms 10264 KB Output is correct
12 Correct 6 ms 9816 KB Output is correct
13 Correct 11 ms 10584 KB Output is correct
14 Correct 7 ms 10072 KB Output is correct
15 Correct 11 ms 10072 KB Output is correct
16 Correct 29 ms 11600 KB Output is correct
17 Correct 7 ms 9816 KB Output is correct
18 Partially correct 28 ms 11668 KB Partially correct - number of queries: 5100
19 Correct 6 ms 9812 KB Output is correct
20 Correct 10 ms 10072 KB Output is correct
21 Correct 13 ms 10584 KB Output is correct
22 Correct 7 ms 9816 KB Output is correct
23 Correct 7 ms 9816 KB Output is correct
24 Correct 6 ms 9816 KB Output is correct
25 Correct 21 ms 10968 KB Output is correct
26 Correct 27 ms 10832 KB Output is correct
27 Correct 7 ms 9816 KB Output is correct
28 Correct 30 ms 11732 KB Output is correct
29 Correct 29 ms 11352 KB Output is correct
30 Partially correct 27 ms 11600 KB Partially correct - number of queries: 5066
31 Correct 5 ms 9816 KB Output is correct
32 Correct 9 ms 10404 KB Output is correct
33 Correct 4 ms 9816 KB Output is correct
34 Correct 13 ms 10396 KB Output is correct
35 Correct 8 ms 10072 KB Output is correct
36 Correct 10 ms 10072 KB Output is correct
37 Correct 10 ms 10072 KB Output is correct
38 Correct 7 ms 10068 KB Output is correct
39 Correct 15 ms 10576 KB Output is correct
40 Correct 37 ms 11804 KB Output is correct
41 Correct 20 ms 10832 KB Output is correct
42 Correct 22 ms 10988 KB Output is correct
43 Correct 24 ms 10832 KB Output is correct
44 Correct 12 ms 10576 KB Output is correct
45 Correct 17 ms 10312 KB Output is correct
46 Correct 6 ms 9816 KB Output is correct
47 Correct 17 ms 10576 KB Output is correct
48 Correct 36 ms 11344 KB Output is correct
49 Correct 7 ms 9816 KB Output is correct
50 Partially correct 29 ms 11704 KB Partially correct - number of queries: 5078
51 Correct 15 ms 10584 KB Output is correct
52 Correct 6 ms 9816 KB Output is correct
53 Correct 7 ms 10072 KB Output is correct
54 Correct 17 ms 10584 KB Output is correct
55 Correct 5 ms 9816 KB Output is correct
56 Partially correct 31 ms 11600 KB Partially correct - number of queries: 5127
57 Correct 30 ms 11296 KB Output is correct
58 Correct 20 ms 11100 KB Output is correct
59 Correct 25 ms 11088 KB Output is correct
60 Correct 21 ms 10832 KB Output is correct
61 Correct 7 ms 10072 KB Output is correct
62 Correct 6 ms 9816 KB Output is correct
63 Correct 10 ms 10072 KB Output is correct
64 Correct 7 ms 10072 KB Output is correct
65 Correct 6 ms 9816 KB Output is correct
66 Correct 7 ms 9816 KB Output is correct
67 Correct 6 ms 9816 KB Output is correct
68 Correct 8 ms 9852 KB Output is correct
69 Correct 7 ms 9816 KB Output is correct
70 Correct 8 ms 10072 KB Output is correct
71 Partially correct 35 ms 11596 KB Partially correct - number of queries: 5239
72 Correct 9 ms 10584 KB Output is correct
73 Partially correct 43 ms 11988 KB Partially correct - number of queries: 5176
74 Partially correct 43 ms 11788 KB Partially correct - number of queries: 5203
75 Correct 7 ms 10072 KB Output is correct
76 Correct 38 ms 11708 KB Output is correct
77 Partially correct 27 ms 11860 KB Partially correct - number of queries: 5212
78 Correct 9 ms 10584 KB Output is correct
79 Correct 21 ms 11648 KB Output is correct
80 Partially correct 25 ms 11612 KB Partially correct - number of queries: 5201
81 Partially correct 27 ms 11740 KB Partially correct - number of queries: 5189
82 Partially correct 33 ms 11760 KB Partially correct - number of queries: 5133
83 Correct 7 ms 10072 KB Output is correct
84 Correct 33 ms 12212 KB Output is correct
85 Partially correct 37 ms 11940 KB Partially correct - number of queries: 5171
86 Correct 7 ms 9816 KB Output is correct
87 Correct 7 ms 9816 KB Output is correct
88 Correct 7 ms 9816 KB Output is correct
89 Correct 7 ms 9816 KB Output is correct
90 Correct 6 ms 9816 KB Output is correct
91 Correct 7 ms 9816 KB Output is correct
92 Correct 9 ms 9816 KB Output is correct
93 Correct 7 ms 10328 KB Output is correct
94 Correct 7 ms 10340 KB Output is correct
95 Correct 6 ms 10328 KB Output is correct
96 Correct 8 ms 10584 KB Output is correct
97 Correct 11 ms 9816 KB Output is correct