이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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
//pas = 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;
//}
컴파일 시 표준 에러 (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 ++ )
......
75 | FOR( i , v.size() ){
| ~~~~~~~~~~~~
prize.cpp:75:3: note: in expansion of macro 'FOR'
75 | FOR( i , v.size() ){
| ^~~
prize.cpp:87: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]
87 | if( pas[ 1 ] < ( v.size() - i ) ) v[ i ].s = mid ;
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |