답안 #1012670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012670 2024-07-02T13:33:49 Z ThegeekKnight16 커다란 상품 (IOI17_prize) C++17
20 / 100
64 ms 1376 KB
    #include <bits/stdc++.h>
    #include "prize.h"
    using namespace std;
    int Q = 10000;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    map<int, vector<int>> ans;
     
    vector<int> query(int x)
    {
        if (ans.count(x)) return ans[x];
        return ans[x] = ask(x);
    }
     
    int dc(int ini, int fim, int qMen, int qL, int qR)
    {
        // cerr << "ini: " << ini << ", fim: " << fim << '\n';
      	if (ini == fim-1)
        {
          vector<int> aL = query(ini), aR = query(fim);
          if (aL[0]+aL[1]==0) return ini;
          if (aR[0]+aR[1]==0) return fim;
          return -1;
        }
        if (ini > fim || qL + qR == qMen) return -1;
        if (qMen - (qL + qR) == fim - ini + 1)
        {
            for (int i = ini; i <= fim; i++)
            {
                vector<int> a = query(i);
                if (a[0]+a[1] == 0) return i;
            }
            return -1;
        }
        int mL = (ini+fim)>>1, mR = (ini+fim)>>1;
        vector<int> aL, aR;
        bool excludeL = 0, excludeD = 0;
        while (mL >= ini)
        {
            aL = query(mL);
            if (aL[0]+aL[1] == 0) return mL;
            if (aL[0]+aL[1] < qMen) --mL;
            else break;
        }
        while (mR <= fim)
        {
            aR = query(mR);
            if (aR[0]+aR[1] == 0) return mR;
            if (aR[0]+aR[1] < qMen) ++mR;
            else break;
        }
     
        int x = dc(mR, fim, qMen, aR[0], qR);
        if (x == -1) return dc(ini, mL, qMen, qL, aL[1]);
        return x;
     
    }
     
    int find_best(int n)
    {
        // if (n <= 5000)
        // {
        //     vector<int> ids(n); iota(ids.begin(), ids.end(), 0);
        //     shuffle(ids.begin(), ids.end(), rng);
        //     for (auto i : ids)
        //     {
        //         vector<int> a = query(i);
        //         if (a[0]+a[1] == 0) return i;
        //     }
        // }
        vector<int> ids;
        for (int i = 0; i < 10; i++) ids.push_back(uniform_int_distribution<int>(0, n-1)(rng));
        vector<vector<int>> possQ;
        for (auto x : ids) possQ.push_back(query(x));
        int qMen = 1;
        for (auto &x : possQ) qMen = max(qMen, x[0]+x[1]);
        return dc(0, n-1, qMen, 0, 0);
    }

Compilation message

prize.cpp: In function 'int dc(int, int, int, int, int)':
prize.cpp:36:14: warning: unused variable 'excludeL' [-Wunused-variable]
   36 |         bool excludeL = 0, excludeD = 0;
      |              ^~~~~~~~
prize.cpp:36:28: warning: unused variable 'excludeD' [-Wunused-variable]
   36 |         bool excludeL = 0, excludeD = 0;
      |                            ^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 5 ms 476 KB Output is correct
15 Correct 20 ms 644 KB Output is correct
16 Correct 5 ms 600 KB Output is correct
17 Correct 34 ms 896 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 23 ms 672 KB Output is correct
20 Correct 13 ms 1024 KB Output is correct
21 Correct 20 ms 1192 KB Output is correct
22 Correct 20 ms 600 KB Output is correct
23 Correct 2 ms 448 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 10 ms 600 KB Output is correct
26 Correct 9 ms 460 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 3 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 36 ms 880 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 17 ms 772 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 18 ms 644 KB Output is correct
37 Correct 3 ms 464 KB Output is correct
38 Correct 2 ms 344 KB Output is correct
39 Correct 14 ms 676 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 14 ms 600 KB Output is correct
42 Correct 11 ms 600 KB Output is correct
43 Correct 12 ms 600 KB Output is correct
44 Correct 18 ms 600 KB Output is correct
45 Correct 15 ms 600 KB Output is correct
46 Correct 43 ms 772 KB Output is correct
47 Correct 14 ms 824 KB Output is correct
48 Correct 7 ms 476 KB Output is correct
49 Correct 19 ms 852 KB Output is correct
50 Correct 1 ms 344 KB Output is correct
51 Correct 18 ms 600 KB Output is correct
52 Correct 21 ms 840 KB Output is correct
53 Correct 1 ms 344 KB Output is correct
54 Correct 19 ms 884 KB Output is correct
55 Correct 28 ms 1112 KB Output is correct
56 Correct 1 ms 428 KB Output is correct
57 Correct 10 ms 424 KB Output is correct
58 Correct 11 ms 456 KB Output is correct
59 Correct 8 ms 652 KB Output is correct
60 Correct 11 ms 524 KB Output is correct
61 Correct 1 ms 344 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 1 ms 596 KB Output is correct
64 Correct 1 ms 344 KB Output is correct
65 Correct 1 ms 344 KB Output is correct
66 Correct 4 ms 344 KB Output is correct
67 Correct 1 ms 504 KB Output is correct
68 Correct 3 ms 344 KB Output is correct
69 Correct 2 ms 340 KB Output is correct
70 Correct 1 ms 344 KB Output is correct
71 Correct 30 ms 1048 KB Output is correct
72 Correct 4 ms 452 KB Output is correct
73 Correct 32 ms 896 KB Output is correct
74 Correct 33 ms 1144 KB Output is correct
75 Correct 1 ms 344 KB Output is correct
76 Correct 29 ms 640 KB Output is correct
77 Correct 22 ms 804 KB Output is correct
78 Correct 3 ms 344 KB Output is correct
79 Correct 15 ms 768 KB Output is correct
80 Correct 26 ms 992 KB Output is correct
81 Correct 30 ms 1376 KB Output is correct
82 Correct 24 ms 1032 KB Output is correct
83 Correct 2 ms 344 KB Output is correct
84 Correct 22 ms 844 KB Output is correct
85 Correct 32 ms 848 KB Output is correct
86 Incorrect 64 ms 1360 KB Incorrect
87 Halted 0 ms 0 KB -