답안 #766816

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
766816 2023-06-26T07:45:48 Z danikoynov 커다란 상품 (IOI17_prize) C++14
96.2 / 100
63 ms 1904 KB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
map < int, vector < int > > mp;
map < int, int > used;
int cnt = 0;
vector < int > local_ask(int idx)
{
    if (used[idx])
        return mp[idx];
    cnt ++;
    //if (cnt == 1e4)
    //  while(true);
    used[idx] = 1;
    mp[idx] = ask(idx);
    return mp[idx];
}

const int maxn = 2e5 + 10;
vector < int > st;
int best;
void solve_range(int l, int r)
{
    ///cout << l << " " << r << " " << cnt << endl;
    int m = (l + r) / 2;
    vector < int > lf = local_ask(l);
    vector < int > rf = local_ask(r);
    if (lf[1] == rf[1])
        return;
    while(m > l)
    {
        vector < int > mf = local_ask(m);
        if (mf[0] + mf[1] != best)
        {
            st.push_back(m);
            m --;
        }
        else
        {
            break;
        }
    }
    if (m == l)
    {
        m = (l + r) / 2 + 1;
        while(m < r)
        {
            vector < int > mf = local_ask(m);
            if (mf[0] + mf[1] != best)
                st.push_back(m), m ++;
            else
                break;
        }
    }
    if (m == r)
        return;

    vector < int > mf = local_ask(m);
    if (lf[0] != mf[0])
        solve_range(l, m);
    if (rf[0] != mf[0])
        solve_range(m, r);
}
int find_best(int n)
{
    vector < int > idc;
    for (int i = 0; i < n; i ++)
        idc.push_back(i);
    int nec = min(n, (int)sqrt(n) + 50);
    int mx = -1;
    for (int i = 0; i < nec; i ++)
    {
        vector < int > cur = local_ask(i);
        if (cur[0] + cur[1] > best)
        {
            best = cur[0] + cur[1];
            mx = i;
        }
    }
    int pt = n - 1;
    while(true)
    {
        vector < int > cur = local_ask(pt);
        if (cur[0] + cur[1] == best)
            break;
        pt --;
    }


    for (int i = 0; i < mx; i ++)
        st.push_back(i);
    for (int i = pt + 1; i < n; i ++)
        st.push_back(i);
    solve_range(mx, pt);

    //cout << st.size() << " " << cnt << endl;
    for (int i = 0; i < st.size(); i ++)
    {
        vector < int > cur = local_ask(st[i]);
        if (cur[0] + cur[1] == 0)
            return st[i];
    }
    return -1;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:97:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |     for (int i = 0; i < st.size(); i ++)
      |                     ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1352 KB Output is correct
2 Correct 4 ms 1352 KB Output is correct
3 Correct 4 ms 1352 KB Output is correct
4 Correct 3 ms 1428 KB Output is correct
5 Correct 4 ms 1352 KB Output is correct
6 Correct 3 ms 1480 KB Output is correct
7 Correct 3 ms 1352 KB Output is correct
8 Correct 4 ms 1352 KB Output is correct
9 Correct 3 ms 1436 KB Output is correct
10 Correct 4 ms 1352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1436 KB Output is correct
2 Correct 4 ms 1432 KB Output is correct
3 Correct 5 ms 1432 KB Output is correct
4 Correct 5 ms 1448 KB Output is correct
5 Correct 3 ms 1440 KB Output is correct
6 Correct 3 ms 1440 KB Output is correct
7 Correct 5 ms 1428 KB Output is correct
8 Correct 5 ms 1432 KB Output is correct
9 Correct 5 ms 1436 KB Output is correct
10 Correct 5 ms 1352 KB Output is correct
11 Correct 6 ms 1352 KB Output is correct
12 Correct 5 ms 1436 KB Output is correct
13 Correct 6 ms 1352 KB Output is correct
14 Correct 11 ms 464 KB Output is correct
15 Partially correct 42 ms 1840 KB Partially correct - number of queries: 5030
16 Partially correct 47 ms 1804 KB Partially correct - number of queries: 5252
17 Partially correct 46 ms 1844 KB Partially correct - number of queries: 5255
18 Partially correct 38 ms 1844 KB Partially correct - number of queries: 5253
19 Correct 40 ms 1856 KB Output is correct
20 Correct 33 ms 1108 KB Output is correct
21 Partially correct 52 ms 1816 KB Partially correct - number of queries: 5221
22 Correct 32 ms 1720 KB Output is correct
23 Correct 3 ms 1440 KB Output is correct
24 Correct 10 ms 1432 KB Output is correct
25 Correct 48 ms 1844 KB Output is correct
26 Correct 31 ms 1764 KB Output is correct
27 Correct 4 ms 1428 KB Output is correct
28 Correct 24 ms 1792 KB Output is correct
29 Correct 28 ms 1668 KB Output is correct
30 Partially correct 23 ms 1900 KB Partially correct - number of queries: 5222
31 Partially correct 32 ms 1820 KB Partially correct - number of queries: 5220
32 Correct 5 ms 1436 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Partially correct 49 ms 1808 KB Partially correct - number of queries: 5258
35 Correct 4 ms 1436 KB Output is correct
36 Partially correct 44 ms 1872 KB Partially correct - number of queries: 5221
37 Correct 7 ms 1432 KB Output is correct
38 Correct 6 ms 1352 KB Output is correct
39 Partially correct 47 ms 1896 KB Partially correct - number of queries: 5221
40 Correct 42 ms 1776 KB Output is correct
41 Partially correct 43 ms 1868 KB Partially correct - number of queries: 5257
42 Partially correct 36 ms 1880 KB Partially correct - number of queries: 5257
43 Partially correct 39 ms 1804 KB Partially correct - number of queries: 5123
44 Partially correct 35 ms 1824 KB Partially correct - number of queries: 5256
45 Correct 31 ms 1840 KB Output is correct
46 Partially correct 37 ms 1860 KB Partially correct - number of queries: 5254
47 Correct 22 ms 1904 KB Output is correct
48 Partially correct 23 ms 1896 KB Partially correct - number of queries: 5254
49 Partially correct 47 ms 1844 KB Partially correct - number of queries: 5253
50 Partially correct 41 ms 1848 KB Partially correct - number of queries: 5257
51 Partially correct 44 ms 1864 KB Partially correct - number of queries: 5252
52 Partially correct 41 ms 1836 KB Partially correct - number of queries: 5255
53 Correct 6 ms 1428 KB Output is correct
54 Partially correct 51 ms 1804 KB Partially correct - number of queries: 5226
55 Partially correct 63 ms 1848 KB Partially correct - number of queries: 5253
56 Partially correct 36 ms 1804 KB Partially correct - number of queries: 5250
57 Partially correct 48 ms 1804 KB Partially correct - number of queries: 5219
58 Partially correct 35 ms 1824 KB Partially correct - number of queries: 5254
59 Partially correct 49 ms 1864 KB Partially correct - number of queries: 5256
60 Partially correct 50 ms 1852 KB Partially correct - number of queries: 5220
61 Correct 7 ms 1352 KB Output is correct
62 Correct 3 ms 1432 KB Output is correct
63 Correct 7 ms 1372 KB Output is correct
64 Correct 6 ms 1436 KB Output is correct
65 Correct 6 ms 1440 KB Output is correct
66 Correct 10 ms 1436 KB Output is correct
67 Correct 11 ms 1440 KB Output is correct
68 Correct 4 ms 1432 KB Output is correct
69 Correct 8 ms 1432 KB Output is correct
70 Correct 8 ms 1416 KB Output is correct
71 Partially correct 47 ms 1884 KB Partially correct - number of queries: 5256
72 Correct 5 ms 1352 KB Output is correct
73 Partially correct 42 ms 1780 KB Partially correct - number of queries: 5193
74 Partially correct 37 ms 1848 KB Partially correct - number of queries: 5220
75 Correct 6 ms 1432 KB Output is correct
76 Correct 40 ms 1896 KB Output is correct
77 Partially correct 50 ms 1836 KB Partially correct - number of queries: 5374
78 Correct 5 ms 1436 KB Output is correct
79 Correct 26 ms 1460 KB Output is correct
80 Partially correct 42 ms 1892 KB Partially correct - number of queries: 5380
81 Partially correct 38 ms 1840 KB Partially correct - number of queries: 5364
82 Partially correct 34 ms 1840 KB Partially correct - number of queries: 5318
83 Correct 6 ms 1352 KB Output is correct
84 Correct 45 ms 1696 KB Output is correct
85 Partially correct 35 ms 1784 KB Partially correct - number of queries: 5337
86 Correct 4 ms 1352 KB Output is correct
87 Correct 7 ms 1432 KB Output is correct
88 Correct 6 ms 1352 KB Output is correct
89 Correct 6 ms 1352 KB Output is correct
90 Correct 5 ms 1352 KB Output is correct
91 Correct 6 ms 1352 KB Output is correct
92 Correct 4 ms 1440 KB Output is correct
93 Correct 10 ms 1352 KB Output is correct
94 Correct 9 ms 1352 KB Output is correct
95 Correct 7 ms 1352 KB Output is correct
96 Correct 6 ms 1352 KB Output is correct
97 Correct 5 ms 1352 KB Output is correct