QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#853614 | #9734. Identify Chord | ucup-team087# | AC ✓ | 54ms | 3952kb | C++14 | 6.2kb | 2025-01-11 17:50:54 | 2025-01-11 17:51:03 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
int N;
int mod(int u) {
return (u % N + N) % N;
}
#ifdef LOCAL
vector<vector<int>> D;
void build(int a, int b) {
D.assign(N, vector<int>(N, N));
for (int u = 0; u < N; ++u) D[u][u] = 0;
for (int u = 0; u < N; ++u) {
const int v = (u + 1) % N;
chmin(D[u][v], 1);
chmin(D[v][u], 1);
}
chmin(D[a][b], 1);
chmin(D[b][a], 1);
for (int w = 0; w < N; ++w) for (int u = 0; u < N; ++u) for (int v = 0; v < N; ++v) {
chmin(D[u][v], D[u][w] + D[w][v]);
}
}
int dist(int u, int v) {
return D[mod(u)][mod(v)];
}
void exper() {
for (N = 8; N <= 20; ++N) {
map<pair<int, vector<int>>, vector<pair<int, int>>> f;
for (int a = 0; a < N; ++a) for (int b = a + 1; b < N; ++b) {
if ((a + 1) % N == b) continue;
if ((b + 1) % N == a) continue;
build(a, b);
vector<int> us{0, N/4, 1 + N/2, 1 - N/2};
vector<int> ds;
for (const int u : us) ds.push_back(dist(u, u + N/2));
// cerr<<N<<" "<<a<<" "<<b<<": "<<us<<" "<<ds<<endl;
assert(*min_element(ds.begin(), ds.end()) < N/2);
const int d0 = ds[0];
if (d0 < N/2) {
vector<int> es;
es.push_back((dist(1, N/2) < d0) ? +1 : (dist(-1, N/2) < d0) ? -1 : 0);
es.push_back((dist(0, N/2 + 1) < d0) ? +1 : (dist(0, N/2 - 1) < d0) ? -1 : 0);
f[make_pair(d0, es)].emplace_back(a, b);
}
}
cerr << "N = " << N << endl;
for (const auto &kv : f) {
set<int> ds;
for (const auto &p : kv.second) {
const int a = p.first;
const int b = p.second;
const int d = min((b - a + N) % N, (a - b + N) % N);
ds.insert(d);
}
cerr << kv << " "; pv(ds.begin(), ds.end());
}
cerr << endl;
}
}
#endif
int ask(int u, int v) {
assert(0 <= u); assert(u < N);
assert(0 <= v); assert(v < N);
#ifdef LOCAL
return D[u][v];
#else
printf("? %d %d\n", u + 1, v + 1);
fflush(stdout);
int ret;
scanf("%d", &ret);
return ret;
#endif
}
int sgn(int x) {
return (x < 0) ? -1 : (x > 0) ? +1 : 0;
}
pair<int, int> solve() {
if (N < 8) {
for (int a = 0; a < N; ++a) for (int b = a + 1; b < N; ++b) {
if ((a + 1) % N == b) continue;
if ((b + 1) % N == a) continue;
if (ask(a, b) == 1) return make_pair(a, b);
}
}
int S = 0, T = 0;
auto d = [&](int u, int v) -> int {
return ask(mod(S + u), mod(S + v));
};
int D0 = N/2;
for (const int s : {0, N/4, 1 + N/2, 1 - N/2}) {
S = s;
D0 = d(0, N/2);
if (D0 < N/2) {
break;
}
}
assert(D0 < N/2);
if (D0 == 1) {
return make_pair(mod(S), mod(S + N/2));
}
int e0 = sgn(D0 - d(1, N/2));
int e1 = sgn(D0 - d(0, N/2 + 1));
// if (!e0) e0 = -e1;
// if (!e1) e1 = -e0;
// if (!e0 && !e1) { e0 = +1; e1 = -1; }
if (!e0) e0 = -1;
if (!e1) e1 = -1;
// cerr<<"S = "<<S<<", D0 = "<<D0<<", e0 = "<<e0<<", e1 = "<<e1<<endl;
bool ok = false;
if (e0 > 0) {
if (e1 > 0) {
const int sum = D0 - 1 + N/2;
S = mod(S + (sum - N/2) / 2);
} else {
ok = true;
T = mod(S + N/2);
}
} else {
if (e1 > 0) {
ok = true;
T = mod(S + N/2);
swap(S, T);
} else {
const int sum = N/2 + N + 1 - D0;
S = mod(S + (sum - N/2) / 2);
// cerr<<"sum = "<<sum<<", S = "<<S<<endl;
}
}
if (!ok) {
D0 = d(0, N/2);
if (D0 == 1) {
return make_pair(mod(S), mod(S + N/2));
}
e0 = sgn(D0 - d(1, N/2));
e1 = sgn(D0 - d(0, N/2 + 1));
// cerr<<"S = "<<S<<", D0 = "<<D0<<", e0 = "<<e0<<", e1 = "<<e1<<endl;
// if (!e0) e0 = -e1;
// if (!e1) e1 = -e0;
// if (!e0 && !e1) { e0 = +1; e1 = -1; }
if (!e0) e0 = -1;
if (!e1) e1 = -1;
// assert(e0 != e1);
T = mod(S + N/2);
if (e0 < 0 || e1 > 0) swap(S, T);
}
const int sz = mod(T - S);
const int len = sz - D0 + 1;
cerr<<COLOR("93")<<"S = "<<S<<", T = "<<T<<", D0 = "<<D0<<", sz = "<<sz<<", len = "<<len<<COLOR()<<endl;
int lo = 0, hi = sz - len + 1;
for (; lo + 1 < hi; ) {
const int mid = (lo + hi) / 2;
((d(mid, sz) == D0 - mid) ? lo : hi) = mid;
}
return make_pair(mod(S + lo), mod(S + lo + len));
}
#ifdef LOCAL
void stress() {
for (N = 4; N <= 40; ++N) {
for (int a = 0; a < N; ++a) for (int b = a + 1; b < N; ++b) {
if ((a + 1) % N == b) continue;
if ((b + 1) % N == a) continue;
build(a, b);
cerr << N << " " << a << " " << b << endl;
const auto res = solve();
cerr << " res = " << res << endl;
assert(res == make_pair(a, b) || res == make_pair(b, a));
}
}
}
#endif
int main() {
// exper();
// stress();
int T;
scanf("%d", &T);
for (int t = 0; t < T; ++t) {
scanf("%d", &N);
const auto res = solve();
printf("! %d %d\n", res.first + 1, res.second + 1);
fflush(stdout);
int ret;
scanf("%d", &ret);
if (ret == -1) exit(0);
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3936kb
input:
2 6 2 2 2 1 1 4 1 1
output:
? 1 3 ? 1 4 ? 1 5 ? 2 4 ! 2 4 ? 1 3 ! 1 3
result:
ok ok (2 test cases)
Test #2:
score: 0
Accepted
time: 8ms
memory: 3768kb
input:
1000 15 5 4 6 3 2 1 1 19 5 4 4 1 1 17 5 4 4 1 1 15 6 6 7 7 6 6 4 3 4 1 14 5 4 6 5 4 1 15 3 2 2 1 1 17 8 2 3 1 1 1 20 6 7 7 6 7 5 3 4 1 13 5 5 6 2 1 3 1 1 18 3 4 2 2 3 1 13 4 5 3 2 3 1 14 2 3 3 2 1 3 1 1 17 8 4 3 5 4 3 1 12 5 4 4 1 1 10 5 3 2 4 2 1 1 14 6 5 6 3 2 1 1 19 8 8 7 4 4 3 1 19 6 5 5 4 5 3 2...
output:
? 1 8 ? 2 8 ? 1 9 ? 3 8 ? 4 8 ? 5 8 ! 5 8 ? 1 10 ? 2 10 ? 1 11 ? 3 12 ! 3 12 ? 1 9 ? 2 9 ? 1 10 ? 3 11 ! 3 11 ? 1 8 ? 2 8 ? 1 9 ? 6 13 ? 7 13 ? 6 14 ? 1 6 ? 3 6 ? 2 6 ! 1 3 ? 1 8 ? 2 8 ? 1 9 ? 3 8 ? 2 8 ! 2 5 ? 1 8 ? 2 8 ? 1 9 ? 2 9 ! 2 9 ? 1 9 ? 5 13 ? 6 13 ? 5 14 ? 14 5 ! 14 5 ? 1 11 ? 2 11 ? 1 12...
result:
ok ok (1000 test cases)
Test #3:
score: 0
Accepted
time: 5ms
memory: 3800kb
input:
1000 21 3 4 4 2 3 1 1 1 22 8 7 7 4 5 3 2 3 1 20 5 4 6 3 2 1 1 22 10 9 9 4 3 5 2 3 1 21 9 8 8 5 4 6 3 4 1 21 8 9 7 4 5 5 1 24 11 11 11 5 4 6 3 4 1 22 10 10 9 6 9 9 1 21 4 3 3 2 3 1 1 1 23 8 9 7 4 2 3 1 21 10 4 3 5 2 3 1 24 9 8 8 7 6 8 4 6 5 1 20 9 9 9 9 8 9 5 4 5 1 24 11 10 11 6 3 2 2 1 23 8 9 9 9 10...
output:
? 1 11 ? 2 11 ? 1 12 ? 10 20 ? 11 20 ? 10 21 ? 21 10 ! 21 10 ? 1 12 ? 2 12 ? 1 13 ? 4 15 ? 5 15 ? 4 16 ? 17 4 ? 18 4 ! 17 3 ? 1 11 ? 2 11 ? 1 12 ? 3 11 ? 4 11 ? 5 11 ! 5 11 ? 1 12 ? 2 12 ? 1 13 ? 5 16 ? 6 16 ? 5 17 ? 7 16 ? 8 16 ! 7 15 ? 1 11 ? 2 11 ? 1 12 ? 5 15 ? 6 15 ? 5 16 ? 7 15 ? 8 15 ! 7 13 ?...
result:
ok ok (1000 test cases)
Test #4:
score: 0
Accepted
time: 5ms
memory: 3784kb
input:
1000 25 8 9 9 9 10 8 5 7 6 1 25 6 7 7 5 6 4 3 4 1 25 11 11 12 6 7 5 3 4 1 25 5 4 6 3 4 1 26 12 12 11 7 9 8 8 1 26 11 12 12 7 8 6 4 6 5 1 26 13 11 12 10 6 5 5 6 1 27 12 11 13 6 4 5 5 1 25 9 10 10 8 7 9 4 6 5 1 27 9 8 10 7 7 6 1 27 11 12 10 9 9 8 9 1 27 13 4 3 3 2 3 1 1 1 26 5 6 4 3 4 1 25 11 11 12 10...
output:
? 1 13 ? 2 13 ? 1 14 ? 10 22 ? 11 22 ? 10 23 ? 1 10 ? 3 10 ? 2 10 ! 1 6 ? 1 13 ? 2 13 ? 1 14 ? 11 23 ? 12 23 ? 11 24 ? 25 11 ? 1 11 ! 25 9 ? 1 13 ? 2 13 ? 1 14 ? 8 20 ? 9 20 ? 8 21 ? 23 8 ? 24 8 ! 23 6 ? 1 13 ? 2 13 ? 1 14 ? 3 13 ? 4 13 ! 3 11 ? 1 14 ? 2 14 ? 1 15 ? 20 1 ? 17 1 ? 18 1 ? 19 1 ! 18 20...
result:
ok ok (1000 test cases)
Test #5:
score: 0
Accepted
time: 11ms
memory: 3776kb
input:
1000 29 10 9 9 6 7 5 3 4 1 28 13 13 13 3 4 2 2 3 1 30 3 2 2 1 1 29 4 3 5 4 3 1 28 8 9 9 6 5 7 3 4 1 29 6 5 5 2 3 1 1 1 29 9 10 8 5 5 4 1 28 11 10 12 6 5 5 4 1 30 4 5 5 4 3 5 2 3 1 30 8 9 9 6 5 7 3 4 1 28 11 10 10 9 8 10 5 7 6 1 29 14 13 12 14 7 4 2 1 1 29 11 10 12 9 9 10 1 29 7 8 8 6 5 7 3 4 1 29 14...
output:
? 1 15 ? 2 15 ? 1 16 ? 5 19 ? 6 19 ? 5 20 ? 22 5 ? 23 5 ! 22 3 ? 1 15 ? 2 15 ? 1 16 ? 9 23 ? 10 23 ? 9 24 ? 24 9 ? 25 9 ! 24 8 ? 1 16 ? 2 16 ? 1 17 ? 2 17 ! 2 17 ? 1 15 ? 2 15 ? 1 16 ? 3 15 ? 2 15 ! 2 13 ? 1 15 ? 2 15 ? 1 16 ? 11 25 ? 12 25 ? 11 26 ? 14 25 ? 15 25 ! 14 23 ? 1 15 ? 2 15 ? 1 16 ? 3 17...
result:
ok ok (1000 test cases)
Test #6:
score: 0
Accepted
time: 8ms
memory: 3932kb
input:
1000 32 13 12 14 10 10 9 10 1 30 14 14 13 7 4 3 4 1 32 16 2 3 1 1 1 31 5 4 6 3 2 3 1 32 7 6 6 3 4 2 2 3 1 32 8 7 7 6 7 5 3 4 1 31 15 9 8 10 5 7 6 1 31 6 7 5 3 2 3 1 32 12 11 13 6 3 4 1 30 14 14 13 7 5 6 6 1 31 11 12 12 6 7 5 3 4 1 31 10 11 9 11 10 9 1 33 7 8 8 8 9 7 4 6 5 1 32 11 10 10 1 1 32 6 7 7 ...
output:
? 1 17 ? 2 17 ? 1 18 ? 7 17 ? 4 17 ? 5 17 ? 6 17 ! 5 9 ? 1 16 ? 2 16 ? 1 17 ? 23 1 ? 26 1 ? 28 1 ? 27 1 ! 26 28 ? 1 17 ? 9 25 ? 10 25 ? 9 26 ? 26 9 ! 26 9 ? 1 16 ? 2 16 ? 1 17 ? 3 16 ? 4 16 ? 5 16 ! 4 15 ? 1 17 ? 2 17 ? 1 18 ? 4 20 ? 5 20 ? 4 21 ? 21 4 ? 22 4 ! 21 3 ? 1 17 ? 2 17 ? 1 18 ? 4 20 ? 5 2...
result:
ok ok (1000 test cases)
Test #7:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
1000 34 17 10 11 9 5 7 6 1 33 8 7 9 4 4 3 1 33 11 12 10 6 5 5 4 1 34 11 12 12 5 6 4 3 4 1 34 11 10 10 9 10 8 5 7 6 1 35 14 15 15 15 16 14 8 7 9 9 1 34 8 9 9 4 5 3 2 3 1 34 14 13 13 6 7 5 3 4 1 34 16 15 16 9 13 14 13 1 33 9 10 8 7 7 6 1 33 16 15 14 16 8 5 7 7 1 34 16 16 15 8 4 2 1 1 33 13 14 14 8 7 9...
output:
? 1 18 ? 9 26 ? 10 26 ? 9 27 ? 31 9 ? 33 9 ? 32 9 ! 31 5 ? 1 17 ? 2 17 ? 1 18 ? 5 17 ? 7 17 ? 6 17 ! 6 15 ? 1 17 ? 2 17 ? 1 18 ? 22 1 ? 25 1 ? 23 1 ? 24 1 ! 24 31 ? 1 18 ? 2 18 ? 1 19 ? 13 30 ? 14 30 ? 13 31 ? 32 13 ? 33 13 ! 32 11 ? 1 18 ? 2 18 ? 1 19 ? 6 23 ? 7 23 ? 6 24 ? 27 6 ? 29 6 ? 28 6 ! 27 ...
result:
ok ok (1000 test cases)
Test #8:
score: 0
Accepted
time: 15ms
memory: 3812kb
input:
1000 36 18 17 16 17 9 6 8 9 1 36 3 4 4 3 2 4 2 3 1 36 13 12 14 12 10 11 1 36 5 4 6 3 4 1 36 18 9 10 8 5 7 6 1 36 12 11 11 8 7 9 4 6 5 1 35 13 14 12 11 10 9 10 1 36 13 12 12 9 8 10 5 7 6 1 36 14 13 13 4 5 3 2 3 1 36 16 15 17 8 6 8 9 1 36 9 8 8 1 1 36 8 9 9 2 3 1 1 1 36 17 16 17 9 5 4 4 1 36 15 14 14 ...
output:
? 1 19 ? 10 28 ? 11 28 ? 10 29 ? 18 28 ? 22 28 ? 20 28 ? 19 28 ! 18 20 ? 1 19 ? 2 19 ? 1 20 ? 18 36 ? 19 36 ? 18 1 ? 19 36 ? 20 36 ! 19 35 ? 1 19 ? 2 19 ? 1 20 ? 7 19 ? 4 19 ? 5 19 ! 4 10 ? 1 19 ? 2 19 ? 1 20 ? 3 19 ? 4 19 ! 3 17 ? 1 19 ? 10 28 ? 11 28 ? 10 29 ? 32 10 ? 34 10 ? 33 10 ! 32 6 ? 1 19 ?...
result:
ok ok (1000 test cases)
Test #9:
score: 0
Accepted
time: 13ms
memory: 3812kb
input:
1000 37 17 17 18 6 5 7 3 4 1 36 17 17 16 10 13 11 10 1 38 9 8 10 5 3 4 1 37 15 14 14 11 10 12 6 9 7 1 37 12 13 13 11 10 12 6 9 7 1 36 8 9 7 4 6 5 1 37 6 7 5 3 4 1 37 18 3 4 2 2 1 1 37 17 17 18 16 15 17 8 6 8 9 1 37 8 7 7 4 3 5 2 3 1 37 10 11 9 5 3 4 1 37 18 18 18 17 16 18 9 5 3 2 1 1 36 3 4 2 2 3 1 ...
output:
? 1 19 ? 2 19 ? 1 20 ? 11 29 ? 12 29 ? 11 30 ? 14 29 ? 15 29 ! 14 27 ? 1 19 ? 2 19 ? 1 20 ? 27 1 ? 23 1 ? 25 1 ? 26 1 ! 26 28 ? 1 20 ? 2 20 ? 1 21 ? 5 20 ? 7 20 ? 8 20 ! 7 18 ? 1 19 ? 2 19 ? 1 20 ? 8 26 ? 9 26 ? 8 27 ? 13 26 ? 16 26 ? 14 26 ! 13 21 ? 1 19 ? 2 19 ? 1 20 ? 14 32 ? 15 32 ? 14 33 ? 19 3...
result:
ok ok (1000 test cases)
Test #10:
score: 0
Accepted
time: 3ms
memory: 3760kb
input:
1000 39 18 17 17 8 7 9 4 6 5 1 38 8 9 7 10 8 7 1 38 19 9 8 10 5 5 4 1 39 12 11 13 13 13 11 12 1 38 15 16 14 12 16 14 15 1 39 4 5 3 2 1 1 39 18 18 19 15 16 14 8 9 10 9 1 38 18 17 18 9 5 3 2 1 1 39 14 15 13 7 4 2 1 1 39 11 10 12 6 5 5 4 1 39 9 8 8 5 6 4 3 4 1 38 19 18 17 18 9 6 8 9 1 39 15 16 16 10 9 ...
output:
? 1 20 ? 2 20 ? 1 21 ? 9 28 ? 10 28 ? 9 29 ? 13 28 ? 15 28 ? 14 28 ! 13 25 ? 1 20 ? 2 20 ? 1 21 ? 24 1 ? 22 1 ? 21 1 ! 21 33 ? 1 20 ? 10 29 ? 11 29 ? 10 30 ? 14 29 ? 16 29 ? 15 29 ! 15 26 ? 1 20 ? 2 20 ? 1 21 ? 7 20 ? 4 20 ? 2 20 ? 3 20 ! 2 10 ? 1 20 ? 2 20 ? 1 21 ? 27 1 ? 23 1 ? 21 1 ? 22 1 ! 21 26...
result:
ok ok (1000 test cases)
Test #11:
score: 0
Accepted
time: 15ms
memory: 3944kb
input:
1000 40 12 11 11 2 1 3 1 1 40 18 17 17 6 5 7 3 4 1 40 15 14 14 11 12 10 6 9 7 1 40 8 9 9 8 9 7 4 6 5 1 40 16 17 15 12 16 14 15 1 40 15 16 16 3 2 4 2 3 1 41 13 14 14 14 15 13 7 10 8 1 40 7 8 6 4 6 5 1 40 18 19 17 11 16 16 17 1 40 6 5 7 3 4 1 40 4 3 5 4 3 1 41 12 11 11 6 7 5 3 4 1 40 17 18 18 3 2 4 2 ...
output:
? 1 21 ? 2 21 ? 1 22 ? 6 26 ? 7 26 ? 6 27 ? 7 26 ! 7 26 ? 1 21 ? 2 21 ? 1 22 ? 9 29 ? 10 29 ? 9 30 ? 12 29 ? 13 29 ! 12 27 ? 1 21 ? 2 21 ? 1 22 ? 8 28 ? 9 28 ? 8 29 ? 33 8 ? 36 8 ? 34 8 ! 33 3 ? 1 21 ? 2 21 ? 1 22 ? 17 37 ? 18 37 ? 17 38 ? 1 17 ? 3 17 ? 2 17 ! 1 14 ? 1 21 ? 2 21 ? 1 22 ? 29 1 ? 25 1...
result:
ok ok (1000 test cases)
Test #12:
score: 0
Accepted
time: 10ms
memory: 3864kb
input:
1000 42 11 10 12 6 9 7 1 41 17 18 16 9 5 7 6 1 41 8 9 9 5 6 4 3 4 1 41 12 13 13 1 1 41 12 11 11 8 7 9 4 6 5 1 41 18 19 19 9 10 8 5 7 6 1 41 14 15 13 7 4 2 3 1 41 20 1 1 41 17 18 18 10 11 9 5 7 6 1 41 15 16 14 14 12 14 13 1 41 18 19 19 1 1 42 20 19 20 11 15 13 12 12 1 41 18 19 19 7 6 8 4 6 5 1 41 8 9...
output:
? 1 22 ? 2 22 ? 1 23 ? 6 22 ? 9 22 ? 7 22 ! 6 17 ? 1 21 ? 2 21 ? 1 22 ? 29 1 ? 33 1 ? 35 1 ? 34 1 ! 33 38 ? 1 21 ? 2 21 ? 1 22 ? 18 38 ? 19 38 ? 18 39 ? 40 18 ? 41 18 ! 40 16 ? 1 21 ? 2 21 ? 1 22 ? 16 36 ! 16 36 ? 1 21 ? 2 21 ? 1 22 ? 6 26 ? 7 26 ? 6 27 ? 10 26 ? 12 26 ? 11 26 ! 10 23 ? 1 21 ? 2 21 ...
result:
ok ok (1000 test cases)
Test #13:
score: 0
Accepted
time: 21ms
memory: 3820kb
input:
1000 43 4 3 5 2 3 1 42 18 17 19 9 5 3 4 1 43 6 5 7 3 2 3 1 43 18 19 19 1 1 43 21 15 16 14 8 10 8 7 1 43 17 18 18 8 9 7 4 6 5 1 43 18 17 19 12 17 16 17 1 43 21 21 21 20 19 21 10 5 3 2 1 1 42 13 14 12 7 10 8 1 42 20 20 19 11 15 13 12 11 1 42 5 6 6 1 1 43 5 6 6 6 7 5 3 4 1 42 21 11 10 12 6 7 5 6 1 43 2...
output:
? 1 22 ? 2 22 ? 1 23 ? 3 22 ? 4 22 ! 3 21 ? 1 22 ? 2 22 ? 1 23 ? 10 22 ? 14 22 ? 16 22 ? 17 22 ! 16 20 ? 1 22 ? 2 22 ? 1 23 ? 4 22 ? 5 22 ? 6 22 ! 5 21 ? 1 22 ? 2 22 ? 1 23 ? 14 35 ! 14 35 ? 1 22 ? 11 32 ? 12 32 ? 11 33 ? 39 11 ? 43 11 ? 41 11 ? 40 11 ! 40 5 ? 1 22 ? 2 22 ? 1 23 ? 14 35 ? 15 35 ? 14...
result:
ok ok (1000 test cases)
Test #14:
score: 0
Accepted
time: 20ms
memory: 3864kb
input:
1000 44 22 14 15 13 7 10 8 1 44 11 10 10 3 4 2 2 3 1 43 11 12 10 12 9 10 1 43 21 12 11 13 6 7 5 6 1 44 19 18 18 17 18 16 9 10 11 10 1 44 16 15 17 14 12 14 13 1 44 17 18 18 13 12 14 7 10 8 1 44 10 9 9 6 5 7 3 4 1 43 13 14 14 8 7 9 4 6 5 1 43 4 5 3 4 3 1 44 9 8 10 5 3 4 1 44 20 21 21 20 21 19 10 7 10 ...
output:
? 1 23 ? 12 34 ? 13 34 ? 12 35 ? 41 12 ? 44 12 ? 42 12 ! 41 6 ? 1 23 ? 2 23 ? 1 24 ? 6 28 ? 7 28 ? 6 29 ? 29 6 ? 30 6 ! 29 5 ? 1 22 ? 2 22 ? 1 23 ? 27 1 ? 24 1 ? 25 1 ! 24 36 ? 1 22 ? 11 32 ? 12 32 ? 11 33 ? 17 32 ? 20 32 ? 18 32 ? 19 32 ! 18 28 ? 1 23 ? 2 23 ? 1 24 ? 10 32 ? 11 32 ? 10 33 ? 40 10 ?...
result:
ok ok (1000 test cases)
Test #15:
score: 0
Accepted
time: 18ms
memory: 3872kb
input:
1000 45 20 21 21 19 20 18 10 9 12 11 1 45 16 17 17 9 10 8 5 7 6 1 45 10 9 11 7 8 7 6 1 45 15 14 14 5 6 4 3 4 1 45 11 10 12 14 11 10 1 45 16 17 17 1 1 45 19 20 18 14 17 17 16 1 45 5 6 6 2 1 3 1 1 44 19 20 18 10 8 8 9 1 45 12 13 11 6 3 2 1 1 44 20 21 19 10 7 10 9 1 45 15 14 16 15 14 14 13 1 44 16 17 1...
output:
? 1 23 ? 2 23 ? 1 24 ? 14 36 ? 15 36 ? 14 37 ? 45 14 ? 5 14 ? 2 14 ? 1 14 ! 45 5 ? 1 23 ? 2 23 ? 1 24 ? 16 38 ? 17 38 ? 16 39 ? 42 16 ? 44 16 ? 43 16 ! 42 12 ? 1 23 ? 2 23 ? 1 24 ? 6 23 ? 3 23 ? 4 23 ? 5 23 ! 5 18 ? 1 23 ? 2 23 ? 1 24 ? 8 30 ? 9 30 ? 8 31 ? 32 8 ? 33 8 ! 32 6 ? 1 23 ? 2 23 ? 1 24 ? ...
result:
ok ok (1000 test cases)
Test #16:
score: 0
Accepted
time: 24ms
memory: 3784kb
input:
1000 46 18 17 17 4 3 5 2 3 1 46 9 8 8 3 4 2 2 3 1 46 22 21 21 10 11 9 5 7 6 1 46 19 18 20 14 15 15 14 1 46 5 6 6 5 6 4 3 4 1 46 21 20 20 7 6 8 4 6 5 1 46 18 17 17 6 5 7 3 4 1 46 16 15 15 8 7 9 4 6 5 1 46 22 22 21 12 18 21 21 1 46 5 4 4 3 4 2 2 3 1 45 19 20 18 10 9 8 7 8 1 46 14 15 15 6 7 5 3 4 1 46 ...
output:
? 1 24 ? 2 24 ? 1 25 ? 9 32 ? 10 32 ? 9 33 ? 11 32 ? 12 32 ! 11 31 ? 1 24 ? 2 24 ? 1 25 ? 5 28 ? 6 28 ? 5 29 ? 29 5 ? 30 5 ! 29 4 ? 1 24 ? 2 24 ? 1 25 ? 11 34 ? 12 34 ? 11 35 ? 39 11 ? 41 11 ? 40 11 ! 39 7 ? 1 24 ? 2 24 ? 1 25 ? 10 24 ? 5 24 ? 7 24 ? 6 24 ! 6 11 ? 1 24 ? 2 24 ? 1 25 ? 22 45 ? 23 45 ...
result:
ok ok (1000 test cases)
Test #17:
score: 0
Accepted
time: 17ms
memory: 3828kb
input:
1000 1000000000 499999999 499999999 499999998 250000000 125000001 187500000 156250000 140625000 132812500 128906250 126953126 127929689 128417969 128173829 128051759 127990724 127960206 127944948 127952578 127956392 127954485 127953531 127953054 127952816 127952697 127952637 127952608 127952622 1279...
output:
? 1 500000001 ? 2 500000001 ? 1 500000002 ? 750000000 1 ? 875000000 1 ? 812500000 1 ? 843750000 1 ? 859375000 1 ? 867187500 1 ? 871093750 1 ? 873046875 1 ? 872070312 1 ? 871582031 1 ? 871826171 1 ? 871948241 1 ? 872009276 1 ? 872039794 1 ? 872055053 1 ? 872047423 1 ? 872043608 1 ? 872045515 1 ? 8720...
result:
ok ok (1000 test cases)
Test #18:
score: 0
Accepted
time: 47ms
memory: 3864kb
input:
1000 1000000000 499999969 499999968 499999970 249999985 124999993 62500028 93750026 109374994 101562495 97656245 95703151 96679714 97167964 96923824 96801754 96740750 96771237 96755978 96748380 96752164 96750257 96749303 96748857 96749096 96749184 96749125 96749099 96749110 96749103 96749099 9674909...
output:
? 1 500000001 ? 2 500000001 ? 1 500000002 ? 249999985 500000001 ? 374999977 500000001 ? 437499973 500000001 ? 406249975 500000001 ? 390624976 500000001 ? 398437475 500000001 ? 402343725 500000001 ? 404296850 500000001 ? 403320287 500000001 ? 402832006 500000001 ? 403076146 500000001 ? 403198216 5000...
result:
ok ok (1000 test cases)
Test #19:
score: 0
Accepted
time: 13ms
memory: 3844kb
input:
1000 1000000000 474148191 474148190 474148190 1 1 1000000000 479245617 479245618 479245618 1 1 1000000000 456055561 456055562 456055562 1 1 1000000000 451495967 451495966 451495966 1 1 1000000000 352188969 352188970 352188970 1 1 1000000000 382036479 382036480 382036480 1 1 1000000000 336574439 3365...
output:
? 1 500000001 ? 2 500000001 ? 1 500000002 ? 237074096 737074096 ! 237074096 737074096 ? 1 500000001 ? 2 500000001 ? 1 500000002 ? 260377193 760377193 ! 260377193 760377193 ? 1 500000001 ? 2 500000001 ? 1 500000002 ? 271972221 771972221 ! 271972221 771972221 ? 1 500000001 ? 2 500000001 ? 1 500000002 ...
result:
ok ok (1000 test cases)
Test #20:
score: 0
Accepted
time: 4ms
memory: 3844kb
input:
1000 1000000000 230485382 230485383 230485383 72 71 73 36 54 45 40 38 37 1 1000000000 237329401 237329400 237329400 87 88 86 44 66 55 49 46 45 1 1000000000 311862190 311862191 311862191 48 47 49 24 36 30 27 25 1 1000000000 156641543 156641542 156641542 55 56 54 28 42 35 31 29 1 1000000000 74201459 7...
output:
? 1 500000001 ? 2 500000001 ? 1 500000002 ? 384757310 884757310 ? 384757311 884757310 ? 384757310 884757311 ? 384757346 884757310 ? 384757364 884757310 ? 384757355 884757310 ? 384757350 884757310 ? 384757348 884757310 ? 384757347 884757310 ! 384757346 884757275 ? 1 500000001 ? 2 500000001 ? 1 500000...
result:
ok ok (1000 test cases)
Test #21:
score: 0
Accepted
time: 42ms
memory: 3952kb
input:
1000 1000000000 288090905 288090906 288090904 144045453 72022727 47732738 54017046 45014205 43231317 42763495 42105962 42200818 41919479 41965292 41894957 41884312 41877373 41875521 41872977 41873323 41872224 41872427 41872152 41872087 41872083 41872053 41872066 41872057 41872053 41872051 41872052 1...
output:
? 1 500000001 ? 2 500000001 ? 1 500000002 ? 644045453 1 ? 716068179 1 ? 752079542 1 ? 734073860 1 ? 743076701 1 ? 747578121 1 ? 745327411 1 ? 746452766 1 ? 745890088 1 ? 746171427 1 ? 746312096 1 ? 746241761 1 ? 746206594 1 ? 746224177 1 ? 746215385 1 ? 746219781 1 ? 746217583 1 ? 746218682 1 ? 7462...
result:
ok ok (1000 test cases)
Test #22:
score: 0
Accepted
time: 36ms
memory: 3800kb
input:
1000 999999999 499999998 499999997 499999999 250000000 374999999 312499999 281250000 296874999 289062499 285156249 283203124 282226562 281738281 281494140 281372071 281433105 281402588 281387329 281379701 281383515 281381608 281380655 281381132 281381371 281381489 281381431 281381460 281381446 28138...
output:
? 1 500000000 ? 2 500000000 ? 1 500000001 ? 250000000 500000000 ? 125000000 500000000 ? 187500000 500000000 ? 218750000 500000000 ? 203125000 500000000 ? 210937500 500000000 ? 214843750 500000000 ? 216796875 500000000 ? 217773437 500000000 ? 218261718 500000000 ? 218505859 500000000 ? 218627929 5000...
result:
ok ok (1000 test cases)
Test #23:
score: 0
Accepted
time: 36ms
memory: 3940kb
input:
1000 999999999 499999957 499999958 499999956 250000022 374999968 312499974 281250020 296875019 304687518 308593768 310546893 311523455 312011693 311767596 311889623 311828588 311798114 311813373 311821002 311824774 311822910 311823821 311823387 311823626 311823745 311823805 311823835 311823831 31182...
output:
? 1 500000000 ? 2 500000000 ? 1 500000001 ? 749999978 1 ? 624999989 1 ? 687499983 1 ? 718749980 1 ? 703124981 1 ? 695312482 1 ? 691406232 1 ? 689453107 1 ? 688476545 1 ? 687988264 1 ? 688232404 1 ? 688110334 1 ? 688171369 1 ? 688201886 1 ? 688186627 1 ? 688178998 1 ? 688175183 1 ? 688177090 1 ? 6881...
result:
ok ok (1000 test cases)
Test #24:
score: 0
Accepted
time: 3ms
memory: 3940kb
input:
1000 999999999 324545945 324545944 324545944 1 1 999999999 446446636 446446635 446446635 2 3 1 1 1 999999999 213858247 213858248 213858248 2 3 1 1 1 999999999 109610987 109610986 109610986 1 1 999999999 277972125 277972126 277972126 2 3 1 1 1 999999999 326547317 326547316 326547316 1 1 999999999 439...
output:
? 1 500000000 ? 2 500000000 ? 1 500000001 ? 162272973 662272972 ! 162272973 662272972 ? 1 500000000 ? 2 500000000 ? 1 500000001 ? 223223318 723223317 ? 223223319 723223317 ? 223223318 723223318 ? 723223318 223223318 ! 723223318 223223318 ? 1 500000000 ? 2 500000000 ? 1 500000001 ? 393070877 89307087...
result:
ok ok (1000 test cases)
Test #25:
score: 0
Accepted
time: 13ms
memory: 3868kb
input:
1000 999999999 487015083 487015084 487015084 66 65 67 33 49 41 37 35 34 1 999999999 307120211 307120210 307120210 47 46 48 24 36 30 27 25 1 999999999 7900378 7900377 7900377 80 79 81 40 60 50 45 42 41 1 999999999 19154051 19154050 19154050 27 28 26 14 21 17 15 1 999999999 315086044 315086043 3150860...
output:
? 1 500000000 ? 2 500000000 ? 1 500000001 ? 256492459 756492458 ? 256492460 756492458 ? 256492459 756492459 ? 256492492 756492458 ? 256492508 756492458 ? 256492500 756492458 ? 256492496 756492458 ? 256492494 756492458 ? 256492493 756492458 ! 256492492 756492426 ? 1 500000000 ? 2 500000000 ? 1 500000...
result:
ok ok (1000 test cases)
Test #26:
score: 0
Accepted
time: 16ms
memory: 3940kb
input:
1000 999999999 265285129 265285128 265285128 249264885 249264886 249264884 124632443 186948664 155790553 140211498 132421970 128527206 126579824 125606133 125119288 124875865 124754154 124693298 124662870 124647656 124640049 124636246 124634344 124633393 124632918 124632680 124632561 124632502 12463...
output:
? 1 500000000 ? 2 500000000 ? 1 500000001 ? 132642565 632642564 ? 132642566 632642564 ? 132642565 632642565 ? 757275006 132642565 ? 819591227 132642565 ? 788433116 132642565 ? 772854061 132642565 ? 765064533 132642565 ? 761169769 132642565 ? 759222387 132642565 ? 758248696 132642565 ? 757761851 1326...
result:
ok ok (1000 test cases)
Test #27:
score: 0
Accepted
time: 28ms
memory: 3872kb
input:
1000 536870912 261621269 261621270 261621270 108355805 108355804 108355806 54177903 81266854 67722378 60950140 57564021 55870962 55024432 54601167 54389535 54283719 54230811 54204357 54191130 54184516 54181209 54179556 54178729 54178316 54178109 54178006 54177954 54177928 54177915 54177909 54177906 ...
output:
? 1 268435457 ? 2 268435457 ? 1 268435458 ? 137624823 406060279 ? 137624824 406060279 ? 137624823 406060280 ? 191802725 406060279 ? 218891676 406060279 ? 205347200 406060279 ? 198574962 406060279 ? 195188843 406060279 ? 193495784 406060279 ? 192649254 406060279 ? 192225989 406060279 ? 192014357 4060...
result:
ok ok (1000 test cases)
Test #28:
score: 0
Accepted
time: 54ms
memory: 3784kb
input:
1000 536870911 244408485 244408486 244408484 122204243 67657826 91653183 76377653 68739888 64921005 65748384 64793663 64443645 64554983 64435643 64383975 64405808 64390890 64383431 64380246 64381566 64380634 64380168 64380013 64380051 64379993 64379984 64379978 64379977 64379974 64379976 64379975 1 ...
output:
? 1 268435456 ? 2 268435456 ? 1 268435457 ? 390639698 1 ? 451741819 1 ? 421190758 1 ? 436466288 1 ? 444104053 1 ? 447922936 1 ? 449832377 1 ? 448877656 1 ? 448400296 1 ? 448638976 1 ? 448519636 1 ? 448459966 1 ? 448489801 1 ? 448474883 1 ? 448467424 1 ? 448463695 1 ? 448465559 1 ? 448464627 1 ? 4484...
result:
ok ok (1000 test cases)
Extra Test:
score: 0
Extra Test Passed