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>
using namespace std;
typedef long long int ll;
typedef long double ld;
#pragma GCC optimize ("Ofast")
#define double ld
const int inf = 2e9;
const int INF = 4e18;
#define F first
#define S second
#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int, int>
#define vpi vector<pi>
#define vb vector<bool>
#define vvb vector<vb>
#define pb push_back
#define read(a) for(auto &x:a) cin >> x;
#define print(a) for(auto x:a) cout << x << " "; cout << "\n";
#define rs resize
#define as assign
#define vc vector<char>
#define vvc vector<vc>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ppb pop_back
#define MP make_pair
//#define int ll
const int mod = 1e9+7;
vi ask(int i);
int find_best(int n){
int ans = -1;
function<void(int, int, vi, vi)> dfs = [&](int l, int r, vi L, vi R){
if(ans != -1 || l+1 >= r || L == R) return;
int mid = (l+r)/2;
vi M = ask(mid);
if(M[0]+M[1] == 0){
ans = mid;
return;
}
if(L[0]+L[1] == R[0]+R[1] && L[0]+L[1] > M[0]+M[1] && L[1]-R[1] == 1) return;
dfs(l, mid, L, M); dfs(mid, r, M, R);
};
vi L = ask(0);
if(L[0]+L[1] == 0) return 0;
vi R = ask(n-1);
if(R[0]+R[1] == 0) return n-1;
dfs(0, n-1, L, R);
return ans;
}
// signed main(){
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// #ifndef ONLINE_JUDGE
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// #endif
// solve();
// return 0;
// }
Compilation message (stderr)
prize.cpp:9:17: warning: overflow in conversion from 'double' to 'int' changes value from '4.0e+18' to '2147483647' [-Woverflow]
9 | const int INF = 4e18;
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |