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>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
int n, x, y, k = 1, rib, leb, upb, m;
bool examine(int a, int b)
{
string bo;
cout << "examine " << a << " " << b << "\n";
cin >> bo;
if ( bo == "true" )
return 1;
return 0;
}
int main ()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> x >> y;
if ( y < n )
{
while (examine(x, k + y))
{
k = k * 2;
if ( k + y > n )
{
k = n - y;
break;
}
}
} else {
k = 0;
}
int l = y, r = y + k;
while (l + 1 < r)
{
int mid = (l + r) / 2;
if ( examine(x, mid) )
l = mid;
else
r = mid;
}
if ( examine(x, r) )
rib = r;
else
rib = l;
if ( y > 1 )
{
k = 1;
while (examine(x, y - k))
{
k = k * 2;
if ( x - k <= 0 )
{
k = y - 1;
break;
}
}
} else {
k = 0;
}
l = y - k, r = y;
while (l + 1 < r)
{
int mid = (l + r) / 2;
if ( examine(x, mid) )
r = mid;
else
l = mid;
}
if ( examine(x, l) )
leb = l;
else
leb = r;
m = rib - leb + 1;
if ( x > 1 )
{
k = 1;
while (examine(x - k, y))
{
k = k * 2;
if ( x - k <= 0 )
{
k = x - 1;
break;
}
}
} else {
k = 0;
}
l = x - k, r = x;
while (l + 1 < r)
{
int mid = (l + r) / 2;
if ( examine(mid, y) )
r = mid;
else
l = mid;
}
if ( examine(l, y) )
upb = l;
else
upb = r;
y = leb + m / 2;
x = upb + m / 2;
while ( x + 2 * m <= n && examine(x + m * 2, y) )
x += m * 2;
while ( y + 2 * m <= n && examine(x, y + m * 2) )
y += m * 2;
cout << "solution " << x - 2 * m << " " << y - 2 * m << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |