답안 #807299

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
807299 2023-08-04T15:36:38 Z Nelt 커다란 상품 (IOI17_prize) C++17
90 / 100
79 ms 5436 KB
#include "prize.h"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

/* DEFINES */
#define S second
#define F first
#define ll long long
#define ull unsigned long long
#define ld long double
#define npos ULLONG_MAX
#define INF LLONG_MAX
#define vv(a) vector<a>
#define pp(a, b) pair<a, b>
#define pq(a) priority_queue<a>
#define qq(a) queue<a>
#define ss(a) set<a>
#define mm(a, b) map<a, b>
#define ump(a, b) unordered_map<a, b>
#define ANDROID                   \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0);
#define elif else if
#define endl "\n"
#define allc(a) begin(a), end(a)
#define all(a) a, a + sizeof(a) / sizeof(a[0])
#define pb push_back
#define logi(a) __lg(a)
#define sqrt(a) sqrtl(a)
#define mpr make_pair
#define ins insert
using namespace std;
using namespace __gnu_pbds;
using namespace __cxx11;
typedef char chr;
typedef basic_string<chr> str;
template <typename T, typename key = less<T>>
using ordered_set = tree<T, null_type, key, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 2e5 + 5;
vv(int) mp[N];
vv(int) query(ll x)
{
	if (!mp[x].empty())
		return mp[x];
	return mp[x] = ask(x);
}
int find_best(int n)
{
	if (n <= 5000)
	{
		for (int i = 0; i < n; i++)
		{
			std::vector<int> res = query(i);
			if (res[0] + res[1] == 0)
				return i;
		}
	}
	pp(ll, ll) mx = mpr(-INF, -INF);
	ll cnt = 450, ind, l, r, mid;
	vv(int) tmp, tmp1;
	while (cnt--)
	{
		ll i = rng() % n;
		tmp = query(i);
		// cout << i << " ";
		mx = max(mx, mpr(0ll + tmp[0] + tmp[1], i));
	}
	ind = mx.S;
	// cout << ind << " ";
	ll i = 0;
	while (true)
	{
		tmp = query(i);
		if (tmp[0] + tmp[1] == 0)
			return i;
		if (tmp[0] + tmp[1] == mx.F)
			break;
		i++;
	}
	while (i < n)
	{
		while (true)
		{
			tmp = query(i);
			if (tmp[0] + tmp[1] == 0)
				return i;
			if (tmp[0] + tmp[1] == mx.F)
				break;
			i++;
		}
		l = i + 1, r = n - 1;
		tmp1 = query(i);
		while (l <= r)
		{
			mid = (l + r) >> 1;
			tmp = query(mid);
			if (tmp[0] + tmp[1] == 0)
				return mid;
			if (tmp[1] < tmp1[1])
				r = mid - 1, i = mid;
			else
				l = mid + 1;
		}
	}
	return n - 1;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:65:16: warning: variable 'ind' set but not used [-Wunused-but-set-variable]
   65 |  ll cnt = 450, ind, l, r, mid;
      |                ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4944 KB Output is correct
2 Correct 5 ms 4944 KB Output is correct
3 Correct 5 ms 4992 KB Output is correct
4 Correct 5 ms 4996 KB Output is correct
5 Correct 6 ms 4944 KB Output is correct
6 Correct 8 ms 4992 KB Output is correct
7 Correct 6 ms 4944 KB Output is correct
8 Correct 8 ms 4944 KB Output is correct
9 Correct 4 ms 4944 KB Output is correct
10 Correct 8 ms 5004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4996 KB Output is correct
2 Correct 6 ms 5000 KB Output is correct
3 Correct 6 ms 4992 KB Output is correct
4 Correct 8 ms 4992 KB Output is correct
5 Correct 6 ms 5008 KB Output is correct
6 Correct 5 ms 5008 KB Output is correct
7 Correct 4 ms 5012 KB Output is correct
8 Correct 7 ms 4996 KB Output is correct
9 Correct 5 ms 4944 KB Output is correct
10 Correct 6 ms 5008 KB Output is correct
11 Correct 10 ms 5004 KB Output is correct
12 Correct 6 ms 5000 KB Output is correct
13 Correct 9 ms 5128 KB Output is correct
14 Correct 8 ms 5024 KB Output is correct
15 Correct 15 ms 5020 KB Output is correct
16 Partially correct 27 ms 5212 KB Partially correct - number of queries: 7178
17 Correct 6 ms 4996 KB Output is correct
18 Partially correct 79 ms 5196 KB Partially correct - number of queries: 8326
19 Correct 8 ms 4984 KB Output is correct
20 Correct 24 ms 5052 KB Output is correct
21 Correct 24 ms 5000 KB Output is correct
22 Correct 11 ms 5012 KB Output is correct
23 Correct 6 ms 4996 KB Output is correct
24 Correct 7 ms 4996 KB Output is correct
25 Correct 30 ms 5116 KB Output is correct
26 Correct 44 ms 5036 KB Output is correct
27 Correct 7 ms 4944 KB Output is correct
28 Partially correct 70 ms 5220 KB Partially correct - number of queries: 7856
29 Partially correct 51 ms 5116 KB Partially correct - number of queries: 6072
30 Partially correct 76 ms 5184 KB Partially correct - number of queries: 8275
31 Correct 7 ms 4996 KB Output is correct
32 Correct 9 ms 5000 KB Output is correct
33 Correct 2 ms 4944 KB Output is correct
34 Correct 27 ms 5016 KB Output is correct
35 Correct 6 ms 4944 KB Output is correct
36 Correct 22 ms 4992 KB Output is correct
37 Correct 5 ms 5024 KB Output is correct
38 Correct 5 ms 4944 KB Output is correct
39 Correct 18 ms 5092 KB Output is correct
40 Partially correct 60 ms 5116 KB Partially correct - number of queries: 7169
41 Partially correct 50 ms 5116 KB Partially correct - number of queries: 5169
42 Partially correct 46 ms 5112 KB Partially correct - number of queries: 5164
43 Correct 40 ms 5116 KB Output is correct
44 Correct 18 ms 5328 KB Output is correct
45 Correct 20 ms 5012 KB Output is correct
46 Correct 5 ms 4996 KB Output is correct
47 Correct 22 ms 5108 KB Output is correct
48 Partially correct 52 ms 5240 KB Partially correct - number of queries: 6285
49 Correct 8 ms 5124 KB Output is correct
50 Partially correct 31 ms 5244 KB Partially correct - number of queries: 8324
51 Correct 16 ms 5180 KB Output is correct
52 Correct 6 ms 4996 KB Output is correct
53 Correct 5 ms 5096 KB Output is correct
54 Correct 32 ms 5116 KB Output is correct
55 Correct 6 ms 5000 KB Output is correct
56 Partially correct 76 ms 5192 KB Partially correct - number of queries: 8325
57 Partially correct 40 ms 5132 KB Partially correct - number of queries: 6210
58 Partially correct 56 ms 5116 KB Partially correct - number of queries: 6278
59 Partially correct 50 ms 5116 KB Partially correct - number of queries: 5166
60 Correct 24 ms 5116 KB Output is correct
61 Correct 7 ms 4944 KB Output is correct
62 Correct 5 ms 4992 KB Output is correct
63 Correct 8 ms 5000 KB Output is correct
64 Correct 6 ms 4992 KB Output is correct
65 Correct 6 ms 4996 KB Output is correct
66 Correct 9 ms 4988 KB Output is correct
67 Correct 7 ms 4976 KB Output is correct
68 Correct 8 ms 5000 KB Output is correct
69 Correct 11 ms 4996 KB Output is correct
70 Correct 6 ms 4944 KB Output is correct
71 Partially correct 57 ms 5280 KB Partially correct - number of queries: 8257
72 Correct 11 ms 4944 KB Output is correct
73 Partially correct 69 ms 5204 KB Partially correct - number of queries: 8164
74 Partially correct 59 ms 5436 KB Partially correct - number of queries: 8209
75 Correct 9 ms 4944 KB Output is correct
76 Partially correct 66 ms 5152 KB Partially correct - number of queries: 7097
77 Partially correct 48 ms 5204 KB Partially correct - number of queries: 8419
78 Correct 12 ms 5020 KB Output is correct
79 Correct 37 ms 5016 KB Output is correct
80 Partially correct 68 ms 5240 KB Partially correct - number of queries: 8450
81 Partially correct 77 ms 5140 KB Partially correct - number of queries: 8441
82 Partially correct 71 ms 5220 KB Partially correct - number of queries: 8369
83 Correct 7 ms 5012 KB Output is correct
84 Partially correct 65 ms 5180 KB Partially correct - number of queries: 6975
85 Partially correct 49 ms 5280 KB Partially correct - number of queries: 8431
86 Partially correct 47 ms 5200 KB Partially correct - number of queries: 7332
87 Correct 12 ms 5028 KB Output is correct
88 Correct 45 ms 5132 KB Output is correct
89 Partially correct 58 ms 5072 KB Partially correct - number of queries: 6155
90 Correct 9 ms 5020 KB Output is correct
91 Correct 39 ms 5000 KB Output is correct
92 Partially correct 51 ms 5120 KB Partially correct - number of queries: 5621
93 Partially correct 77 ms 5204 KB Partially correct - number of queries: 7522
94 Partially correct 72 ms 5160 KB Partially correct - number of queries: 7780
95 Partially correct 50 ms 5204 KB Partially correct - number of queries: 7408
96 Partially correct 44 ms 5240 KB Partially correct - number of queries: 6521
97 Partially correct 72 ms 5196 KB Partially correct - number of queries: 6999