Submission #789910

#TimeUsernameProblemLanguageResultExecution timeMemory
789910lollipopThe Big Prize (IOI17_prize)C++17
20 / 100
3034 ms5044 KiB
#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 ] ; 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( been[ ( v[ i ].f + v[ i ].s ) / 2 ] == 1 ){ cc ++ ; continue ; } int mid = ( v[ i ].f + v[ i ].s ) / 2 ; if( qu[ mid ].size() == 0 ) pas = ask( mid ) ; else pas = qu[ mid ] ; been[ mid ] = 1 ; qu[ mid ] = pas ; if( pas[ 1 ] + pas[ 0 ] == 0 ) return mid ; 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; //}

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:12:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 | #define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
......
   74 |   FOR( i , v.size() ){
      |        ~~~~~~~~~~~~                      
prize.cpp:74:3: note: in expansion of macro 'FOR'
   74 |   FOR( i , v.size() ){
      |   ^~~
prize.cpp:83:17: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |    if( pas[ 1 ] < ( v.size() - i ) ) v[ i ].s = mid ;
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...