답안 #283728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
283728 2020-08-26T06:17:25 Z ToMmyDong 커다란 상품 (IOI17_prize) C++11
90 / 100
96 ms 1144 KB
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define SZ(i) int(i.size())
#define ALL(i) i.begin(), i.end()
#define MEM(i,a) memset(i, (a), sizeof(i))
#define X first
#define Y second
#define eb emplace_back
#define pb push_back
#ifdef tmd
#define debug(...) fprintf(stderr,"#%d-(%s)=",__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do (T &&x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y) {cerr<<x<<", ";_do(y...);}
#else
#define debug(...)
#endif


map<int, vector<int> > mem;
vector<int> sask (int idx) {
    if (mem.count(idx) == 0) {
        mem[idx] = ask(idx);
    }
    return mem[idx];
}

int find_best(int n) {

    srand(880301);
    int mx = 0;
    for (int i=0; i<50; i++) {
        vector<int> res = sask(rand() % n);
        mx = max(mx, res[0] + res[1]);
    }
    debug(mx);

    int sp = rand() % n;
	for(int i = sp; i < n; i++) {
		std::vector<int> res = sask(i);
		if(res[0] + res[1] == 0) return i;
        if (res[0] + res[1] < mx) continue;
        int L = i, R = n;
        while (L < R - 1) {
            int M = (L + R) >> 1;
            vector<int> resM = sask(M);
            if (resM[0] + resM[1] == 0) return M;
            if (resM == res) {
                L = M;
            } else {
                R = M;
            }
        }
        debug(i, R);
        i = R - 1;
	}
	for(int i = 0; i < sp; i++) {
		std::vector<int> res = sask(i);
		if(res[0] + res[1] == 0) return i;
        if (res[0] + res[1] < mx) continue;
        int L = i, R = sp;
        while (L < R - 1) {
            int M = (L + R) >> 1;
            vector<int> resM = sask(M);
            if (resM[0] + resM[1] == 0) return M;
            if (resM == res) {
                L = M;
            } else {
                R = M;
            }
        }
        debug(i, R);
        i = R - 1;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 388 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 372 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 6 ms 512 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 12 ms 384 KB Output is correct
15 Correct 1 ms 376 KB Output is correct
16 Partially correct 73 ms 888 KB Partially correct - number of queries: 5585
17 Partially correct 61 ms 1016 KB Partially correct - number of queries: 6750
18 Partially correct 72 ms 1144 KB Partially correct - number of queries: 6731
19 Partially correct 82 ms 1016 KB Partially correct - number of queries: 6337
20 Correct 6 ms 376 KB Output is correct
21 Correct 28 ms 504 KB Output is correct
22 Partially correct 67 ms 888 KB Partially correct - number of queries: 5452
23 Correct 1 ms 396 KB Output is correct
24 Correct 8 ms 384 KB Output is correct
25 Correct 41 ms 632 KB Output is correct
26 Correct 40 ms 632 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Partially correct 58 ms 1016 KB Partially correct - number of queries: 6355
29 Correct 55 ms 1016 KB Output is correct
30 Partially correct 83 ms 1144 KB Partially correct - number of queries: 6678
31 Partially correct 69 ms 1016 KB Partially correct - number of queries: 6715
32 Correct 5 ms 384 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 15 ms 504 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 9 ms 384 KB Output is correct
37 Correct 1 ms 388 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 34 ms 632 KB Output is correct
40 Partially correct 72 ms 888 KB Partially correct - number of queries: 5743
41 Correct 38 ms 632 KB Output is correct
42 Correct 47 ms 680 KB Output is correct
43 Correct 32 ms 632 KB Output is correct
44 Correct 26 ms 504 KB Output is correct
45 Correct 12 ms 504 KB Output is correct
46 Partially correct 60 ms 1052 KB Partially correct - number of queries: 6745
47 Correct 27 ms 760 KB Output is correct
48 Correct 50 ms 760 KB Output is correct
49 Partially correct 74 ms 1144 KB Partially correct - number of queries: 7201
50 Partially correct 75 ms 1016 KB Partially correct - number of queries: 6731
51 Correct 29 ms 508 KB Output is correct
52 Partially correct 78 ms 1016 KB Partially correct - number of queries: 6831
53 Correct 3 ms 384 KB Output is correct
54 Correct 23 ms 504 KB Output is correct
55 Partially correct 71 ms 1088 KB Partially correct - number of queries: 6762
56 Partially correct 96 ms 1104 KB Partially correct - number of queries: 6514
57 Correct 43 ms 760 KB Output is correct
58 Correct 63 ms 764 KB Output is correct
59 Correct 45 ms 632 KB Output is correct
60 Correct 37 ms 776 KB Output is correct
61 Correct 3 ms 384 KB Output is correct
62 Correct 3 ms 384 KB Output is correct
63 Correct 2 ms 376 KB Output is correct
64 Correct 3 ms 384 KB Output is correct
65 Correct 1 ms 376 KB Output is correct
66 Correct 6 ms 376 KB Output is correct
67 Correct 1 ms 512 KB Output is correct
68 Correct 7 ms 384 KB Output is correct
69 Correct 7 ms 376 KB Output is correct
70 Correct 1 ms 380 KB Output is correct
71 Partially correct 40 ms 1112 KB Partially correct - number of queries: 6681
72 Correct 6 ms 384 KB Output is correct
73 Partially correct 71 ms 1144 KB Partially correct - number of queries: 6594
74 Partially correct 74 ms 1060 KB Partially correct - number of queries: 6635
75 Correct 2 ms 384 KB Output is correct
76 Partially correct 58 ms 888 KB Partially correct - number of queries: 5660
77 Partially correct 62 ms 1016 KB Partially correct - number of queries: 6807
78 Correct 6 ms 384 KB Output is correct
79 Correct 45 ms 632 KB Output is correct
80 Partially correct 78 ms 1128 KB Partially correct - number of queries: 6818
81 Partially correct 71 ms 1016 KB Partially correct - number of queries: 6808
82 Partially correct 66 ms 1020 KB Partially correct - number of queries: 6750
83 Correct 3 ms 384 KB Output is correct
84 Partially correct 57 ms 888 KB Partially correct - number of queries: 5565
85 Partially correct 53 ms 1116 KB Partially correct - number of queries: 6814
86 Correct 27 ms 884 KB Output is correct
87 Correct 6 ms 384 KB Output is correct
88 Correct 25 ms 504 KB Output is correct
89 Correct 21 ms 512 KB Output is correct
90 Correct 2 ms 384 KB Output is correct
91 Correct 34 ms 632 KB Output is correct
92 Correct 1 ms 256 KB Output is correct
93 Correct 5 ms 384 KB Output is correct
94 Correct 5 ms 384 KB Output is correct
95 Correct 7 ms 384 KB Output is correct
96 Correct 5 ms 384 KB Output is correct
97 Correct 2 ms 256 KB Output is correct