답안 #263327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
263327 2020-08-13T15:38:24 Z discoverMeMe 커다란 상품 (IOI17_prize) C++14
97.7 / 100
76 ms 2180 KB
//big cheese
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; using namespace __gnu_pbds;
//#pragma GCC optimize("Ofast") //#pragma GCC optimize "unroll-loops" //#pragma GCC optimize "prefetch-loop-arrays" //#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,aes,sse4a,sse4.1,sse4.2,mmx,popcnt,tune=native"
#define foru(i,a,b) for(int i=(a);i<(b);i++)
#define ford(i,a,b) for(int i=(a);i>=(b);i--)
#define fori(a,b) foru(i,a,b)
#define forj(a,b) foru(j,a,b)
#define fork(a,b) foru(k,a,b)
#define seto(x,i) memset(x,i,sizeof x)
#define pf first
#define ps second
#define pb push_back
#define eb emplace_back
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define clz __builtin_clz
#define clzll __builtin_clzll
#define ctz __builtin_ctz
#define ctzll __builtin_ctzll
#define P2(x) (1LL<<(x))
#define sz(x) (int)x.size()
#define all(x) begin(x),end(x)
#if __SIZEOF_INT128__
    typedef __int128_t i128; typedef __uint128_t ui128;
#else
    typedef long long i128; typedef unsigned long long ui128;
#endif
typedef int64_t ll;  typedef uint64_t ull; typedef int8_t byte; typedef long double lld;
typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<lld,lld> pdd;
template<typename T1,typename T2> using ordered_map=tree<T1,T2,less<T1>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename T1> using ordered_set=ordered_map<T1,null_type>;
const int inf=0x3f3f3f3f,MOD=1e9+7; const ll INF=0x3f3f3f3f3f3f3f3f; const lld PI=acos((lld)-1);
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll fpow(ll a,ll b){if(!b) return 1; ll t=fpow(a,b/2); if(b&1) return t*t%MOD*a%MOD; return t*t%MOD;}
const ll SEED=chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count();
mt19937 randgen(SEED); int randint(int a, int b){return uniform_int_distribution<int>(a,b)(randgen);} ll randll(ll a, ll b){return uniform_int_distribution<ll>(a,b)(randgen);}
template<class T1,class T2>constexpr const auto _min(const T1&x,const T2&y){return x<y?x:y;} template<class T,class...Ts>constexpr auto _min(const T&x,const Ts&...xs){return _min(x,_min(xs...));}
template<class T1,class T2>constexpr const auto _max(const T1&x,const T2&y){return x>y?x:y;} template<class T,class...Ts>constexpr auto _max(const T&x,const Ts&...xs){return _max(x,_max(xs...));}
#define min(...) _min(__VA_ARGS__)
#define max(...) _max(__VA_ARGS__)
struct chash{
    static ll splitmix64(ll x){x+=0x9e3779b97f4a7c15; x=(x^(x>>30))*0xbf58476d1ce4e5b9; x=(x^(x>>27))*0x94d049bb133111eb; return x^(x>>31);}
    template<class T> size_t operator()(const T &x) const{return splitmix64(hash<T>()(x)+SEED);}
    template<class T1,class T2> size_t operator()(const pair<T1,T2>&x)const{return 31*operator()(x.first)+operator()(x.second);}
};
#define nl "\n"
 
const int N=200010,M=472;
int n,lol,ans,qans[N][2];
bitset<N> done,ps;
 
int prizes[N],cnt;
vector<int> ask(int x);
/*
vector<int> ask(int x){
    vector<int> ret; ret.resize(2); cnt++;
    fori(0,x) if(prizes[i]<prizes[x]) ret[0]++;
    fori(x+1,n) if(prizes[i]<prizes[x]) ret[1]++;
    return ret;
}//*/
void query(int x){
    if(done[x]) return;
    auto ret=ask(x); qans[x][0]=ret[0]; qans[x][1]=ret[0]+ret[1]; done[x]=1; cnt++;
    if(!qans[x][1]) ans=x;
}
 
bool go(int l,int r,int v){
    if(ans!=-1) return 0;
    int mid=(l+r)/2; query(mid);
    if(l>r) return 0;
    if(qans[mid][1]<lol){
        if(ps[mid]) return go(mid+1,r,v);
        if(!go(l,mid-1,v)){
            ps[mid]=1; return 1;
        }
    }
    if(qans[mid][0]>v) return go(l,mid-1,v);
    if(qans[mid][0]<=v) return go(mid+1,r,v);
}
int find_best(int _n){
    n=_n; ans=-1;
    fori(0,min(n,M)){
        query(i);
        lol=max(lol,qans[i][1]);
    }
    fori(0,lol) go(0,n-1,i);
    //assert(cnt<=5010);
    assert(ans!=-1);
    return ans;
}

Compilation message

prize.cpp: In function 'bool go(int, int, int)':
prize.cpp:83:1: warning: control reaches end of non-void function [-Wreturn-type]
   83 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 368 KB Output is correct
2 Correct 9 ms 388 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 7 ms 372 KB Output is correct
5 Correct 5 ms 388 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 3 ms 388 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 388 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 8 ms 364 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 392 KB Output is correct
7 Correct 6 ms 396 KB Output is correct
8 Correct 9 ms 504 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 400 KB Output is correct
11 Correct 12 ms 624 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 7 ms 956 KB Output is correct
14 Correct 7 ms 420 KB Output is correct
15 Correct 11 ms 632 KB Output is correct
16 Correct 24 ms 1692 KB Output is correct
17 Correct 4 ms 376 KB Output is correct
18 Partially correct 51 ms 1928 KB Partially correct - number of queries: 5077
19 Correct 4 ms 396 KB Output is correct
20 Correct 15 ms 632 KB Output is correct
21 Correct 22 ms 960 KB Output is correct
22 Correct 9 ms 512 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 9 ms 384 KB Output is correct
25 Correct 25 ms 1144 KB Output is correct
26 Correct 25 ms 1272 KB Output is correct
27 Correct 7 ms 384 KB Output is correct
28 Correct 37 ms 1784 KB Output is correct
29 Correct 35 ms 1656 KB Output is correct
30 Partially correct 62 ms 1912 KB Partially correct - number of queries: 5038
31 Correct 10 ms 376 KB Output is correct
32 Correct 10 ms 768 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 28 ms 888 KB Output is correct
35 Correct 4 ms 496 KB Output is correct
36 Correct 12 ms 768 KB Output is correct
37 Correct 5 ms 504 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 20 ms 1104 KB Output is correct
40 Correct 40 ms 1912 KB Output is correct
41 Correct 27 ms 1272 KB Output is correct
42 Correct 47 ms 1272 KB Output is correct
43 Correct 28 ms 1144 KB Output is correct
44 Correct 22 ms 1016 KB Output is correct
45 Correct 11 ms 1000 KB Output is correct
46 Correct 3 ms 388 KB Output is correct
47 Correct 34 ms 1008 KB Output is correct
48 Correct 31 ms 1528 KB Output is correct
49 Correct 6 ms 448 KB Output is correct
50 Partially correct 63 ms 1988 KB Partially correct - number of queries: 5080
51 Correct 12 ms 988 KB Output is correct
52 Correct 4 ms 384 KB Output is correct
53 Correct 9 ms 632 KB Output is correct
54 Correct 28 ms 1016 KB Output is correct
55 Correct 4 ms 376 KB Output is correct
56 Partially correct 41 ms 1912 KB Partially correct - number of queries: 5089
57 Correct 30 ms 1456 KB Output is correct
58 Correct 22 ms 1456 KB Output is correct
59 Correct 47 ms 1316 KB Output is correct
60 Correct 47 ms 1144 KB Output is correct
61 Correct 8 ms 640 KB Output is correct
62 Correct 10 ms 384 KB Output is correct
63 Correct 7 ms 632 KB Output is correct
64 Correct 6 ms 512 KB Output is correct
65 Correct 7 ms 504 KB Output is correct
66 Correct 11 ms 384 KB Output is correct
67 Correct 3 ms 396 KB Output is correct
68 Correct 4 ms 384 KB Output is correct
69 Correct 8 ms 384 KB Output is correct
70 Correct 9 ms 384 KB Output is correct
71 Partially correct 39 ms 2180 KB Partially correct - number of queries: 5230
72 Correct 9 ms 1016 KB Output is correct
73 Partially correct 43 ms 2044 KB Partially correct - number of queries: 5167
74 Partially correct 46 ms 2048 KB Partially correct - number of queries: 5194
75 Correct 8 ms 640 KB Output is correct
76 Correct 32 ms 1940 KB Output is correct
77 Partially correct 46 ms 1952 KB Partially correct - number of queries: 5230
78 Correct 6 ms 1028 KB Output is correct
79 Correct 50 ms 1916 KB Output is correct
80 Partially correct 51 ms 1912 KB Partially correct - number of queries: 5230
81 Partially correct 76 ms 1912 KB Partially correct - number of queries: 5229
82 Partially correct 46 ms 1912 KB Partially correct - number of queries: 5176
83 Correct 7 ms 640 KB Output is correct
84 Correct 44 ms 2052 KB Output is correct
85 Partially correct 60 ms 1912 KB Partially correct - number of queries: 5204
86 Correct 8 ms 384 KB Output is correct
87 Correct 8 ms 384 KB Output is correct
88 Correct 7 ms 384 KB Output is correct
89 Correct 8 ms 392 KB Output is correct
90 Correct 5 ms 384 KB Output is correct
91 Correct 6 ms 376 KB Output is correct
92 Correct 5 ms 384 KB Output is correct
93 Correct 7 ms 768 KB Output is correct
94 Correct 8 ms 768 KB Output is correct
95 Correct 11 ms 760 KB Output is correct
96 Correct 5 ms 720 KB Output is correct
97 Correct 5 ms 384 KB Output is correct