# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
789915 | lollipop | The Big Prize (IOI17_prize) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
//#define int long long
#define pb push_back
#define s second
#define f first
#define pf push_front
#define inf 100000000000000000
#define bitebi __builtin_popcountll
#define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
#define YES cout <<"YES\n"
#define NO cout << "NO\n"
#define debug cout << "Here Fine" << endl ;
#define pr pair < int , int >
#define fbo find_by_order // returns iterator
#define ook order_of_key // returns strictly less numbers than key
using namespace std ;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const double Pi=acos(-1.0);
const double EPS=1E-8;
const int mod = 1000000007 ;
const int mod1 = 998244353 ;
const int N = 2e5 + 10 ;
mt19937 R(time(0));
map < int , int > ma , ma1 ;
#include "prize.h"
//static const int max_q = 10000;
//static int n;
//static int query_count = 0;
//static vector<int> g;
//static vector<vector<int> > rank_count;
//
//vector<int> ask(int i) {
// query_count++;
// if(query_count > max_q) {
// cerr << "Query limit exceeded" << endl;
// exit(0);
// }
//
// if(i < 0 || i >= n) {
// cerr << "Bad index: " << i << endl;
// exit(0);
// }
//
// vector<int> res(2);
// res[0] = rank_count[g[i] - 1][i + 1];
// res[1] = rank_count[g[i] - 1][n] - res[0];
// return res;
//}
vector < int > qu[ N ] ;
map < pair < int , pair < int , int > > , int > bn ;
int been[ N ] ;
int find_best(int n){
int mx = 0 ;
vector < int > pas ;
FOR( i , 480 ){
pas = ask( i ) ;
if( pas[ 0 ] + pas[ 1 ] == 0 ) return i ;
qu[ i ] = pas ;
mx = max( mx , pas[ 0 ] + pas[ 1 ] ) ;
}
vector < pair < int , int > > v ;
FOR( i , mx ) v.pb( { 0 , n - 1 } ) ;
while( true ){
int cc = 0 ;
FOR( i , v.size() ){
if( bn[ { i , { v[ i ].f , v[ i ].s } } ] == 2 ){
cc ++ ; continue ; }
bn[ { i , { v[ i ].f , v[ i ].s } } ++ ;
int mid = ( v[ i ].f + v[ i ].s ) / 2 ;
//if( qu[ mid ].size() == 0 ) pas = ask( mid ) ;
//else
as = qu[ mid ] ;
qu[ mid ] = pas ;
if( pas[ 1 ] + pas[ 0 ] == 0 ) return mid ;
// if( v[ i ].f == v[ i ].s && mid == v[ i ].f ) been[ i ] = 1 ;
if( pas[ 1 ] < ( v.size() - i ) ) v[ i ].s = mid ;
else v[ i ].f = mid + 1 ;
}
// if( cc == v.size() ) return 0 ;
}
}
//int main() {
// cin >> n;
//
// g.resize(n);
// for(int i = 0; i < n; i++) {
// cin >> g[i];
// if(g[i] < 1) {
// cerr << "Invalid rank " << g[i] << " at index " << i << endl;
// exit(0);
// }
// }
//
// int max_rank = *max_element(g.begin(), g.end());
//
// rank_count.resize(max_rank + 1, vector<int>(n + 1, 0));
// for(int r = 0; r <= max_rank; r++) {
// for(int i = 1; i <= n; i++) {
// rank_count[r][i] = rank_count[r][i - 1];
// if(g[i - 1] == r)
// rank_count[r][i]++;
// }
// }
//
// for(int i = 0; i <= n; i++)
// for(int r = 1; r <= max_rank; r++)
// rank_count[r][i] += rank_count[r - 1][i];
//
// int res = find_best(n);
// cout << res << endl << "Query count: " << query_count << endl;
//
// return 0;
//}