#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define eb emplace_back
#define pre(a) cout<<fixed; cout.precision(a)
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const long long INF = 1e18;
const int inf = 1e9;
ll n, M;
ll x, y;
pll s, e;
pll ans;
bool ask(ll i, ll j) {
cout << "examine " << i << " " << j << endl;
string s;
cin >> s;
return s == "true";
}
int main() {
cin >> n >> x >> y;
ll l = x, r = n;
while(l != r) {
ll m = l + r + 1 >> 1;
if(ask(m, y)) l = m;
else r = m-1;
}
e.fi = l;
l = 1, r = x;
while(l != r) {
ll m = l + r >> 1;
if(ask(m, y)) r = m;
else l = m+1;
}
s.fi = l;
l = y, r = n;
while(l != r) {
ll m = l + r + 1 >> 1;
if(ask(x, m)) l = m;
else r = m-1;
}
e.se = l;
l = 1, r = y;
while(l != r) {
ll m = l + r >> 1;
if(ask(x, m)) r = m;
else l = m+1;
}
s.se = l;
if(!ask(s.fi + e.fi >> 1, y)) M = (e.fi - s.fi + 1) / 3;
else if(!ask(3 * s.fi + e.fi >> 1, y)) M = (e.fi - s.fi + 1) / 5;
else M = e.fi - s.fi + 1;
x = s.fi + M / 2;
y = s.se + M / 2;
//cout << "!!!!!!!!!!!!!!!!!!!!!!!!! " << x << " " << y << endl;
ll cnt = 0;
for(ll i = x - 4*M; i<=x + 4*M; i += 2*M) {
if(i < 1 || i > n) continue;
if(ask(i, y)) cnt++, ans.fi += i;
}
if(cnt > 0) ans.fi /= cnt;
cnt = 0;
for(ll i = y - 4*M; i <= y + 4*M; i += 2*M) {
if(i < 1 || i > n) continue;
if(ask(x, i)) cnt++, ans.se += i;
}
if(cnt > 0) ans.se /= cnt;
cout << "solution " << ans.fi << " " << ans.se << endl;
}
Compilation message
aliens.cpp: In function 'int main()':
aliens.cpp:39:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
ll m = l + r + 1 >> 1;
~~~~~~^~~
aliens.cpp:50:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
ll m = l + r >> 1;
~~^~~
aliens.cpp:61:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
ll m = l + r + 1 >> 1;
~~~~~~^~~
aliens.cpp:72:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
ll m = l + r >> 1;
~~^~~
aliens.cpp:81:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
if(!ask(s.fi + e.fi >> 1, y)) M = (e.fi - s.fi + 1) / 3;
^
aliens.cpp:82:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
else if(!ask(3 * s.fi + e.fi >> 1, y)) M = (e.fi - s.fi + 1) / 5;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3079 ms |
376 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
248 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Output is correct |
2 |
Correct |
7 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Incorrect |
7 ms |
376 KB |
Incorrect |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
248 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
248 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
6 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
252 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Correct |
8 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
248 KB |
Expected int32, but "3450034355" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Incorrect |
7 ms |
248 KB |
Expected int32, but "3992620059" found |
3 |
Halted |
0 ms |
0 KB |
- |