QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#869385 | #9734. Identify Chord | hos_lyric | AC ✓ | 49ms | 3840kb | C++14 | 4.8kb | 2025-01-25 08:34:29 | 2025-01-25 08:34:32 |
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) < 0) ? (u + N) : u;
}
#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) {
int mx = 0;
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<pair<pair<int, int>, int>> es;
int u = 0, v = N/2;
for (int i = 0; i < N; ++i) {
const int d = dist(u, v);
es.emplace_back(make_pair(u, v), d);
if (d < N/2) goto found;
if (N & 1) {
(i & 1) ? ++u : ++v;
} else {
++u;
++v;
}
}
cerr << "FAIL " << N << " " << a << " " << b << ": " << es << endl;
assert(false);
found:{}
// cerr << N << " " << a << " " << b << ": " << es << endl;
chmax(mx, (int)es.size());
}
cerr << "DONE N = " << N << ": mx = " << mx << endl;
}
}
#endif
int ask(int u, int v) {
u = mod(u);
v = mod(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
}
// u->v uses the chord && u: endpoint
pair<int, int> finish(int u, int v) {
const int d = ask(u, v);
for (const int d0 : {mod(v - u), N - mod(v - u)}) {
const int c = d0 - (d - 1);
// cerr<<"[finish] u = "<<u<<", v = "<<v<<", c = "<<c<<endl;
for (const int w : {u + c, u - c}) {
if (ask(u, w) == 1) return make_pair(mod(u), mod(w));
}
}
assert(false);
}
pair<int, int> solve() {
int u = 0, v = N/2, d;
for (int i = 0; ; ++i) {
d = ask(u, v);
if (d < N/2) break;
if (N & 1) {
(i & 1) ? ++u : ++v;
} else {
++u;
++v;
}
}
u = mod(u);
v = mod(v);
// cerr<<"u = "<<u<<", v = "<<v<<", d = "<<d<<endl;
int dir;
if (ask(u + 1, v) == d - 1) {
dir = +1;
} else if (ask(u - 1, v) == d - 1) {
dir = -1;
} else {
return finish(u, v);
}
int lo = 0, hi = mod((v - u) / dir);
for (; lo + 1 < hi; ) {
const int mid = (lo + hi) / 2;
((ask(u + mid * dir, v) == d - mid) ? lo : hi) = mid;
}
return finish(u + lo * dir, v);
}
#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 << COLOR("93") << N << " " << a << " " << b << COLOR() << endl;
const auto res = solve();
cerr << " res = " << res << endl;
assert(res == make_pair(a, b) || res == make_pair(b, a));
}
}
}
#endif
int main() {
// exper(); return 0;
// stress(); return 0;
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: 0ms
memory: 3840kb
input:
2 6 2 1 1 1 1 1 1 4 1 1 1 1 1 1
output:
? 1 4 ? 2 4 ? 2 4 ? 3 4 ? 2 4 ? 2 4 ! 2 4 ? 1 3 ? 2 3 ? 4 3 ? 1 3 ? 1 3 ! 1 3
result:
ok ok (2 test cases)
Test #2:
score: 0
Accepted
time: 10ms
memory: 3840kb
input:
1000 15 5 4 2 2 1 1 1 1 19 5 4 5 3 4 3 5 5 2 1 1 17 5 4 4 3 4 3 4 4 2 1 1 15 6 6 7 6 1 1 14 5 4 4 4 5 4 1 1 15 3 2 4 2 3 2 3 4 2 1 1 17 8 8 8 7 6 5 5 4 4 3 3 2 1 1 20 6 7 7 6 1 1 13 5 5 4 2 2 3 2 1 1 18 3 4 2 5 3 2 2 3 3 5 1 1 13 4 5 3 4 3 4 3 5 2 4 1 1 14 2 3 1 3 1 2 1 1 1 17 8 7 6 3 3 2 2 3 3 5 1 ...
output:
? 1 8 ? 2 8 ? 4 8 ? 6 8 ? 5 8 ? 5 8 ? 5 8 ! 5 8 ? 1 10 ? 2 10 ? 5 10 ? 3 10 ? 4 10 ? 3 10 ? 3 8 ? 3 17 ? 3 13 ? 3 12 ! 3 12 ? 1 9 ? 2 9 ? 5 9 ? 3 9 ? 4 9 ? 3 9 ? 3 7 ? 3 16 ? 3 12 ? 3 11 ! 3 11 ? 1 8 ? 2 8 ? 15 8 ? 1 8 ? 1 3 ! 1 3 ? 1 8 ? 2 8 ? 4 8 ? 2 8 ? 3 8 ? 2 8 ? 2 5 ! 2 5 ? 1 8 ? 2 8 ? 4 8 ? 2...
result:
ok ok (1000 test cases)
Test #3:
score: 0
Accepted
time: 16ms
memory: 3712kb
input:
1000 21 3 4 2 6 3 2 2 1 1 22 8 7 6 6 7 6 4 4 7 1 1 20 5 4 2 3 2 1 1 1 1 22 10 9 5 3 4 4 4 2 2 7 1 1 21 9 8 4 3 3 3 2 2 6 1 1 21 8 9 7 6 6 5 6 5 9 6 4 1 1 24 11 11 10 5 3 4 4 4 1 1 22 10 10 9 5 2 2 2 3 4 2 1 1 21 4 3 5 4 3 3 5 4 2 1 1 23 8 9 7 6 9 7 8 7 6 2 5 1 1 21 10 10 10 9 8 4 3 3 4 3 3 3 7 1 1 2...
output:
? 1 11 ? 2 11 ? 21 11 ? 17 11 ? 20 11 ? 21 11 ? 21 11 ? 21 10 ! 21 10 ? 1 12 ? 2 12 ? 6 12 ? 3 12 ? 4 12 ? 3 12 ? 3 7 ? 3 21 ? 3 11 ? 3 17 ! 3 17 ? 1 11 ? 2 11 ? 6 11 ? 3 11 ? 4 11 ? 5 11 ? 5 11 ? 5 11 ! 5 11 ? 1 12 ? 2 12 ? 6 12 ? 9 12 ? 7 12 ? 8 12 ? 7 12 ? 7 9 ? 7 5 ? 7 21 ? 7 15 ! 7 15 ? 1 11 ? ...
result:
ok ok (1000 test cases)
Test #4:
score: 0
Accepted
time: 10ms
memory: 3840kb
input:
1000 25 8 9 9 8 1 1 25 6 7 5 7 7 5 6 5 1 1 25 11 11 10 7 8 9 8 1 1 25 5 4 6 4 4 3 3 1 1 26 12 12 11 6 4 5 5 5 9 10 2 1 1 26 11 12 10 7 10 10 9 9 1 1 26 13 13 11 12 12 11 3 1 1 27 12 11 6 4 5 5 5 1 1 25 9 10 8 3 2 2 1 1 1 1 27 9 8 7 6 7 6 1 1 27 11 12 10 4 4 5 4 7 10 4 1 1 27 13 13 13 13 12 11 7 9 8 ...
output:
? 1 13 ? 2 13 ? 25 13 ? 1 13 ? 1 6 ! 1 6 ? 1 13 ? 2 13 ? 25 13 ? 20 13 ? 23 13 ? 25 13 ? 24 13 ? 25 13 ? 25 9 ! 25 9 ? 1 13 ? 2 13 ? 25 13 ? 20 13 ? 23 13 ? 22 13 ? 23 13 ? 23 6 ! 23 6 ? 1 13 ? 2 13 ? 7 13 ? 4 13 ? 2 13 ? 3 13 ? 3 13 ? 3 11 ! 3 11 ? 1 14 ? 2 14 ? 26 14 ? 21 14 ? 18 14 ? 20 14 ? 19 1...
result:
ok ok (1000 test cases)
Test #5:
score: 0
Accepted
time: 15ms
memory: 3712kb
input:
1000 29 10 9 7 9 9 8 8 5 5 10 1 1 28 13 13 12 7 10 8 8 8 1 1 30 3 2 8 4 2 3 2 3 3 1 1 29 4 3 7 5 3 4 3 1 1 28 8 9 7 3 5 3 2 2 1 1 29 6 5 7 5 5 4 4 7 6 2 1 1 29 9 10 8 8 6 8 7 6 11 6 7 1 1 28 11 10 4 4 5 4 1 1 30 4 5 3 5 1 3 2 1 1 1 30 8 9 7 3 5 3 2 2 1 1 28 11 10 4 3 3 2 2 3 4 6 1 1 29 14 13 14 12 6...
output:
? 1 15 ? 2 15 ? 8 15 ? 4 15 ? 2 15 ? 3 15 ? 3 15 ? 3 8 ? 3 27 ? 3 13 ? 3 22 ! 3 22 ? 1 15 ? 2 15 ? 28 15 ? 22 15 ? 26 15 ? 24 15 ? 23 15 ? 24 15 ? 24 8 ! 24 8 ? 1 16 ? 2 16 ? 8 16 ? 4 16 ? 2 16 ? 3 16 ? 2 16 ? 2 15 ? 2 19 ? 2 17 ! 2 17 ? 1 15 ? 2 15 ? 8 15 ? 4 15 ? 2 15 ? 3 15 ? 2 15 ? 2 13 ! 2 13 ?...
result:
ok ok (1000 test cases)
Test #6:
score: 0
Accepted
time: 10ms
memory: 3840kb
input:
1000 32 13 12 8 9 10 10 9 1 1 30 14 14 13 8 11 10 11 11 8 7 2 1 1 32 16 16 14 13 8 10 8 9 8 3 3 3 1 1 31 5 4 6 2 4 3 2 1 1 32 7 6 8 7 5 6 5 9 5 5 1 1 32 8 7 8 10 8 7 7 9 3 11 1 1 31 15 14 13 6 4 4 3 3 3 3 7 1 1 31 6 7 5 8 8 6 5 5 9 2 10 1 1 32 12 11 4 4 4 3 3 1 1 30 14 14 13 8 11 9 9 9 12 11 2 1 1 3...
output:
? 1 17 ? 2 17 ? 9 17 ? 5 17 ? 7 17 ? 6 17 ? 5 17 ? 5 9 ! 5 9 ? 1 16 ? 2 16 ? 30 16 ? 24 16 ? 28 16 ? 26 16 ? 27 16 ? 28 16 ? 28 6 ? 28 20 ? 28 30 ? 28 26 ! 28 26 ? 1 17 ? 2 18 ? 3 19 ? 4 19 ? 11 19 ? 7 19 ? 9 19 ? 10 19 ? 9 19 ? 9 12 ? 9 6 ? 9 24 ? 9 26 ! 9 26 ? 1 16 ? 2 16 ? 8 16 ? 4 16 ? 6 16 ? 5 ...
result:
ok ok (1000 test cases)
Test #7:
score: 0
Accepted
time: 23ms
memory: 3712kb
input:
1000 34 17 16 15 9 13 14 13 13 2 2 8 1 1 33 8 7 6 4 4 3 3 1 1 33 11 12 10 9 9 9 8 8 12 6 7 1 1 34 11 12 10 9 9 9 8 8 1 1 34 11 10 9 13 11 10 10 7 3 9 1 1 35 14 15 15 14 1 1 34 8 9 7 9 8 6 7 6 1 1 34 14 13 9 10 11 11 10 4 4 11 1 1 34 16 15 9 13 14 13 13 1 1 33 9 10 8 7 5 5 4 4 7 10 9 1 1 33 16 16 16 ...
output:
? 1 18 ? 2 19 ? 3 19 ? 10 19 ? 6 19 ? 4 19 ? 5 19 ? 5 19 ? 5 7 ? 5 3 ? 5 13 ? 5 31 ! 5 31 ? 1 17 ? 2 17 ? 9 17 ? 5 17 ? 7 17 ? 6 17 ? 6 17 ? 6 15 ! 6 15 ? 1 17 ? 2 17 ? 33 17 ? 26 17 ? 30 17 ? 32 17 ? 31 17 ? 31 17 ? 31 10 ? 31 19 ? 31 5 ? 31 24 ! 31 24 ? 1 18 ? 2 18 ? 34 18 ? 27 18 ? 31 18 ? 33 18 ...
result:
ok ok (1000 test cases)
Test #8:
score: 0
Accepted
time: 10ms
memory: 3712kb
input:
1000 36 18 17 16 8 4 2 1 1 1 1 1 36 3 4 2 8 3 1 2 1 1 1 36 13 12 9 11 11 10 10 1 1 36 5 4 9 5 3 4 3 1 1 36 18 17 16 9 13 12 13 13 2 2 10 1 1 36 12 11 3 5 5 4 3 5 7 11 1 1 35 13 14 12 6 9 7 6 5 5 9 14 6 1 1 36 13 12 4 5 4 3 3 5 6 10 1 1 36 14 13 9 10 10 9 9 5 5 7 1 1 36 16 15 9 12 10 9 8 8 1 1 36 9 8...
output:
? 1 19 ? 2 20 ? 3 20 ? 11 20 ? 15 20 ? 17 20 ? 18 20 ? 19 20 ? 18 20 ? 18 20 ! 18 20 ? 1 19 ? 2 19 ? 36 19 ? 28 19 ? 33 19 ? 35 19 ? 34 19 ? 35 19 ? 35 19 ! 35 19 ? 1 19 ? 2 19 ? 10 19 ? 5 19 ? 3 19 ? 4 19 ? 4 19 ? 4 10 ! 4 10 ? 1 19 ? 2 19 ? 10 19 ? 5 19 ? 3 19 ? 4 19 ? 3 19 ? 3 17 ! 3 17 ? 1 19 ? ...
result:
ok ok (1000 test cases)
Test #9:
score: 0
Accepted
time: 13ms
memory: 3840kb
input:
1000 37 17 17 16 8 5 6 7 6 1 1 36 17 17 16 8 5 7 8 8 15 16 2 1 1 38 9 8 6 5 3 4 3 1 1 37 15 14 6 4 4 3 3 4 4 8 1 1 37 12 13 11 3 4 1 2 1 1 1 36 8 9 7 9 6 6 5 5 9 7 11 1 1 37 6 7 5 10 6 4 5 4 7 4 10 1 1 37 18 18 18 18 17 16 9 13 11 10 10 10 2 2 4 1 1 37 17 17 16 8 3 1 2 1 1 1 37 8 7 7 4 4 3 3 5 11 8 ...
output:
? 1 19 ? 2 19 ? 37 19 ? 29 19 ? 24 19 ? 27 19 ? 26 19 ? 27 19 ? 27 14 ! 27 14 ? 1 19 ? 2 19 ? 36 19 ? 28 19 ? 24 19 ? 26 19 ? 27 19 ? 28 19 ? 28 12 ? 28 8 ? 28 30 ? 28 26 ! 28 26 ? 1 20 ? 2 20 ? 10 20 ? 5 20 ? 7 20 ? 8 20 ? 7 20 ? 7 18 ! 7 18 ? 1 19 ? 2 19 ? 10 19 ? 14 19 ? 12 19 ? 13 19 ? 13 19 ? 1...
result:
ok ok (1000 test cases)
Test #10:
score: 0
Accepted
time: 10ms
memory: 3712kb
input:
1000 39 18 17 9 5 7 6 6 6 2 2 12 1 1 38 8 9 7 5 4 2 3 2 3 13 12 1 1 38 19 19 17 16 8 5 6 5 6 5 3 3 11 1 1 39 12 11 10 14 12 11 11 1 1 38 15 16 14 6 3 4 3 2 2 3 7 5 1 1 39 4 5 5 4 7 2 6 1 1 39 18 18 17 10 15 16 17 16 1 1 38 18 17 9 4 2 1 1 1 1 1 39 14 15 15 14 6 2 7 1 1 39 11 10 6 7 5 4 5 4 1 1 39 9 ...
output:
? 1 20 ? 2 20 ? 10 20 ? 15 20 ? 12 20 ? 13 20 ? 14 20 ? 13 20 ? 13 15 ? 13 11 ? 13 1 ? 13 25 ! 13 25 ? 1 20 ? 2 20 ? 38 20 ? 30 20 ? 35 20 ? 33 20 ? 32 20 ? 33 20 ? 33 19 ? 33 9 ? 33 7 ? 33 21 ! 33 21 ? 1 20 ? 2 21 ? 3 22 ? 4 22 ? 12 22 ? 17 22 ? 14 22 ? 15 22 ? 16 22 ? 15 22 ? 15 18 ? 15 12 ? 15 4 ...
result:
ok ok (1000 test cases)
Test #11:
score: 0
Accepted
time: 11ms
memory: 3712kb
input:
1000 40 12 11 10 7 7 6 6 9 9 3 1 1 40 18 17 8 5 8 7 7 3 3 11 1 1 40 15 14 10 15 13 14 13 6 5 10 1 1 40 8 9 9 8 1 1 40 16 17 15 6 5 4 3 4 3 5 9 5 1 1 40 15 16 14 9 10 8 7 8 7 1 1 41 13 14 14 13 1 1 40 7 8 6 10 6 5 4 5 4 7 7 13 1 1 40 18 19 17 8 3 3 4 3 5 7 3 1 1 40 6 5 10 5 4 3 4 3 1 1 40 4 3 10 7 4 ...
output:
? 1 21 ? 2 21 ? 11 21 ? 6 21 ? 8 21 ? 7 21 ? 7 21 ? 7 16 ? 7 38 ? 7 28 ? 7 26 ! 7 26 ? 1 21 ? 2 21 ? 11 21 ? 16 21 ? 13 21 ? 12 21 ? 12 21 ? 12 15 ? 12 9 ? 12 37 ? 12 27 ! 12 27 ? 1 21 ? 2 21 ? 11 21 ? 6 21 ? 3 21 ? 4 21 ? 3 21 ? 3 9 ? 3 37 ? 3 13 ? 3 33 ! 3 33 ? 1 21 ? 2 21 ? 40 21 ? 1 21 ? 1 14 ! ...
result:
ok ok (1000 test cases)
Test #12:
score: 0
Accepted
time: 13ms
memory: 3712kb
input:
1000 42 11 10 11 6 8 7 6 1 1 41 17 18 16 11 14 15 14 13 13 12 8 5 1 1 41 8 9 7 11 9 6 7 6 1 1 41 12 13 11 10 7 7 6 6 1 1 41 12 11 4 7 5 4 3 3 5 9 13 1 1 41 18 19 17 11 13 14 14 13 1 1 41 14 15 13 11 16 14 13 13 9 2 8 1 1 41 20 20 19 18 10 14 12 11 10 10 2 2 2 1 1 41 17 18 16 11 14 15 14 13 13 1 1 41...
output:
? 1 22 ? 2 22 ? 11 22 ? 6 22 ? 8 22 ? 7 22 ? 6 22 ? 6 17 ! 6 17 ? 1 21 ? 2 21 ? 41 21 ? 32 21 ? 37 21 ? 40 21 ? 39 21 ? 38 21 ? 38 21 ? 38 9 ? 38 26 ? 38 2 ? 38 33 ! 38 33 ? 1 21 ? 2 21 ? 41 21 ? 32 21 ? 37 21 ? 40 21 ? 39 21 ? 40 21 ? 40 16 ! 40 16 ? 1 21 ? 2 21 ? 41 21 ? 32 21 ? 37 21 ? 35 21 ? 36...
result:
ok ok (1000 test cases)
Test #13:
score: 0
Accepted
time: 8ms
memory: 3840kb
input:
1000 43 4 3 10 5 2 3 2 1 1 42 18 17 8 3 3 4 3 1 1 43 6 5 8 3 4 3 2 2 1 1 43 18 19 17 11 13 10 9 10 9 1 1 43 21 21 21 20 19 11 17 18 17 18 17 3 3 8 1 1 43 17 18 16 11 12 14 13 12 1 1 43 18 17 11 16 16 17 16 1 1 43 21 21 21 20 21 20 20 3 2 2 1 1 42 13 14 12 11 8 8 7 7 13 13 9 1 1 42 20 20 19 10 6 9 10...
output:
? 1 22 ? 2 22 ? 11 22 ? 6 22 ? 3 22 ? 4 22 ? 3 22 ? 3 21 ! 3 21 ? 1 22 ? 2 22 ? 11 22 ? 16 22 ? 19 22 ? 17 22 ? 16 22 ? 16 20 ! 16 20 ? 1 22 ? 2 22 ? 11 22 ? 6 22 ? 3 22 ? 4 22 ? 5 22 ? 5 22 ? 5 21 ! 5 21 ? 1 22 ? 2 22 ? 43 22 ? 33 22 ? 39 22 ? 36 22 ? 35 22 ? 34 22 ? 35 22 ? 35 14 ! 35 14 ? 1 22 ? ...
result:
ok ok (1000 test cases)
Test #14:
score: 0
Accepted
time: 16ms
memory: 3712kb
input:
1000 44 22 22 20 19 11 17 18 17 18 17 3 3 9 1 1 44 11 10 11 8 9 8 7 7 12 9 5 1 1 43 11 12 10 6 6 3 4 3 5 16 12 1 1 43 21 21 21 21 20 19 10 5 3 5 5 2 2 10 1 1 44 19 18 11 17 19 18 18 4 3 6 1 1 44 16 15 11 13 14 13 12 12 1 1 44 17 18 16 6 5 4 3 4 3 1 1 44 10 9 7 5 4 4 3 3 5 13 11 1 1 43 13 14 12 4 8 5...
output:
? 1 23 ? 2 24 ? 3 25 ? 4 25 ? 14 25 ? 8 25 ? 5 25 ? 6 25 ? 7 25 ? 6 25 ? 6 9 ? 6 3 ? 6 15 ? 6 41 ! 6 41 ? 1 23 ? 2 23 ? 12 23 ? 6 23 ? 3 23 ? 4 23 ? 5 23 ? 5 23 ? 5 17 ? 5 37 ? 5 25 ? 5 29 ! 5 29 ? 1 22 ? 2 22 ? 43 22 ? 33 22 ? 39 22 ? 36 22 ? 35 22 ? 36 22 ? 36 20 ? 36 9 ? 36 5 ? 36 24 ! 36 24 ? 1 ...
result:
ok ok (1000 test cases)
Test #15:
score: 0
Accepted
time: 9ms
memory: 3712kb
input:
1000 45 20 21 19 12 18 20 19 19 1 1 45 16 17 15 12 13 14 13 12 12 1 1 45 10 9 11 7 8 7 6 6 1 1 45 15 14 11 10 13 11 10 8 8 8 1 1 45 11 10 11 14 11 10 10 1 1 45 16 17 15 11 11 8 9 8 1 1 45 19 20 18 8 6 5 4 5 4 7 11 5 1 1 45 5 6 4 10 4 3 2 3 2 1 1 44 19 20 18 11 14 13 13 12 12 18 15 4 1 1 45 12 13 13 ...
output:
? 1 23 ? 2 23 ? 45 23 ? 35 23 ? 41 23 ? 44 23 ? 45 23 ? 45 23 ? 45 5 ! 45 5 ? 1 23 ? 2 23 ? 45 23 ? 35 23 ? 41 23 ? 44 23 ? 43 23 ? 42 23 ? 42 23 ? 42 12 ! 42 12 ? 1 23 ? 2 23 ? 12 23 ? 6 23 ? 3 23 ? 4 23 ? 5 23 ? 5 23 ? 5 18 ! 5 18 ? 1 23 ? 2 23 ? 12 23 ? 6 23 ? 9 23 ? 7 23 ? 6 23 ? 6 14 ? 6 43 ? 6...
result:
ok ok (1000 test cases)
Test #16:
score: 0
Accepted
time: 17ms
memory: 3712kb
input:
1000 46 18 17 9 13 10 9 8 8 6 6 7 1 1 46 9 8 12 8 7 6 7 6 11 7 5 1 1 46 22 21 12 17 15 16 16 16 2 2 14 1 1 46 19 18 12 14 15 15 14 1 1 46 5 6 6 5 1 1 46 21 20 10 6 9 9 8 8 3 3 13 1 1 46 18 17 7 6 9 8 7 6 6 11 1 1 46 16 15 5 6 8 6 5 8 8 15 1 1 46 22 22 21 11 5 2 2 2 3 4 2 1 1 46 5 4 12 8 5 4 4 7 3 5 ...
output:
? 1 24 ? 2 24 ? 12 24 ? 6 24 ? 9 24 ? 10 24 ? 11 24 ? 11 24 ? 11 17 ? 11 5 ? 11 37 ? 11 31 ! 11 31 ? 1 24 ? 2 24 ? 12 24 ? 6 24 ? 3 24 ? 4 24 ? 5 24 ? 4 24 ? 4 19 ? 4 35 ? 4 25 ? 4 29 ! 4 29 ? 1 24 ? 2 24 ? 12 24 ? 6 24 ? 9 24 ? 7 24 ? 8 24 ? 7 24 ? 7 9 ? 7 5 ? 7 21 ? 7 39 ! 7 39 ? 1 24 ? 2 24 ? 12 ...
result:
ok ok (1000 test cases)
Test #17:
score: 0
Accepted
time: 34ms
memory: 3840kb
input:
1000 1000000000 499999999 499999999 499999998 250000000 374999999 312500000 343750000 359375000 367187500 371093750 373046874 372070312 371582032 371826173 371948243 372009278 372039796 372055054 372047425 372043611 372045519 372046473 372046950 372047188 372047307 372047367 372047396 372047381 3720...
output:
? 1 500000001 ? 2 500000001 ? 1000000000 500000001 ? 750000001 500000001 ? 875000001 500000001 ? 812500001 500000001 ? 843750001 500000001 ? 859375001 500000001 ? 867187501 500000001 ? 871093751 500000001 ? 873046876 500000001 ? 872070314 500000001 ? 871582033 500000001 ? 871826174 500000001 ? 87194...
result:
ok ok (1000 test cases)
Test #18:
score: 0
Accepted
time: 38ms
memory: 3712kb
input:
1000 1000000000 499999969 499999968 249999969 124999969 62500000 93750000 109374969 101562469 97656219 95703125 96679688 97167938 96923798 96801728 96740724 96771211 96755952 96748354 96752138 96750231 96749277 96748831 96749070 96749158 96749099 96749100 96749110 96749102 96749098 96749098 96749097...
output:
? 1 500000001 ? 2 500000001 ? 250000001 500000001 ? 375000001 500000001 ? 437500001 500000001 ? 406250001 500000001 ? 390625001 500000001 ? 398437501 500000001 ? 402343751 500000001 ? 404296876 500000001 ? 403320313 500000001 ? 402832032 500000001 ? 403076172 500000001 ? 403198242 500000001 ? 403259...
result:
ok ok (1000 test cases)
Test #19:
score: 0
Accepted
time: 35ms
memory: 3712kb
input:
1000 1000000000 474148191 474148190 250000000 349148191 286648191 255398191 239773191 242187501 238281251 237820066 237304688 237331785 237087645 237182617 237121582 237091064 237075805 237080016 237076202 237074295 237074851 237074374 237074135 237074176 237074117 237074105 237074102 237074097 2370...
output:
? 1 500000001 ? 2 500000001 ? 250000001 500000001 ? 125000001 500000001 ? 187500001 500000001 ? 218750001 500000001 ? 234375001 500000001 ? 242187501 500000001 ? 238281251 500000001 ? 236328126 500000001 ? 237304688 500000001 ? 236816407 500000001 ? 237060547 500000001 ? 237182617 500000001 ? 237121...
result:
ok ok (1000 test cases)
Test #20:
score: 0
Accepted
time: 47ms
memory: 3840kb
input:
1000 1000000000 230485382 230485383 230485381 249999930 124999930 167985382 136735382 121110382 117187430 117204132 115251007 116210867 115722586 115478445 115356375 115295340 115264822 115249563 115243378 115245748 115243841 115242887 115242902 115242664 115242767 115242707 115242677 115242662 1152...
output:
? 1 500000001 ? 2 500000001 ? 1000000000 500000001 ? 750000001 500000001 ? 875000001 500000001 ? 937500001 500000001 ? 906250001 500000001 ? 890625001 500000001 ? 882812501 500000001 ? 886718751 500000001 ? 884765626 500000001 ? 883789064 500000001 ? 884277345 500000001 ? 884521486 500000001 ? 88464...
result:
ok ok (1000 test cases)
Test #21:
score: 0
Accepted
time: 49ms
memory: 3712kb
input:
1000 1000000000 288090905 288090906 288090904 250000000 329346805 266846805 256840905 251221805 249028405 247315555 247075280 246338992 246586999 246342859 246220789 246277956 246247438 246232179 246224550 246220735 246218882 246219781 246219304 246219066 246218947 246218887 246218857 246218868 2462...
output:
? 1 500000001 ? 2 500000001 ? 1000000000 500000001 ? 750000001 500000001 ? 875000001 500000001 ? 937500001 500000001 ? 968750001 500000001 ? 953125001 500000001 ? 960937501 500000001 ? 957031251 500000001 ? 958984376 500000001 ? 958007814 500000001 ? 958496095 500000001 ? 958251955 500000001 ? 95812...
result:
ok ok (1000 test cases)
Test #22:
score: 0
Accepted
time: 48ms
memory: 3840kb
input:
1000 999999999 499999998 499999997 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 281381453 28138...
output:
? 1 500000000 ? 2 500000000 ? 250000000 500000000 ? 125000000 500000000 ? 187500000 500000000 ? 218750000 500000000 ? 203125000 500000000 ? 210937500 500000000 ? 214843750 500000000 ? 216796875 500000000 ? 217773437 500000000 ? 218261718 500000000 ? 218505859 500000000 ? 218627929 500000000 ? 218566...
result:
ok ok (1000 test cases)
Test #23:
score: 0
Accepted
time: 43ms
memory: 3840kb
input:
1000 999999999 499999957 499999958 499999956 249999957 125000000 187500000 218749957 203124957 195312457 191406207 189453082 188476520 187988282 188232380 188110353 188171388 188201863 188186604 188178975 188175203 188177068 188176157 188176591 188176353 188176234 188176174 188176144 188176149 18817...
output:
? 1 500000000 ? 2 500000000 ? 999999999 500000000 ? 750000000 500000000 ? 625000000 500000000 ? 687500000 500000000 ? 718750000 500000000 ? 703125000 500000000 ? 695312500 500000000 ? 691406250 500000000 ? 689453125 500000000 ? 688476563 500000000 ? 687988282 500000000 ? 688232423 500000000 ? 688110...
result:
ok ok (1000 test cases)
Test #24:
score: 0
Accepted
time: 30ms
memory: 3840kb
input:
1000 999999999 324545945 324545944 250000000 199545946 187500000 168295946 171875000 164062500 164389696 162436571 163085937 162597656 162353515 162314501 162292480 162283984 162277221 162276355 162273406 162274448 162273494 162273017 162273167 162273048 162272988 162272988 162272973 162272980 16227...
output:
? 1 500000000 ? 2 500000000 ? 250000000 500000000 ? 125000000 500000000 ? 187500000 500000000 ? 156250000 500000000 ? 171875000 500000000 ? 164062500 500000000 ? 160156250 500000000 ? 162109375 500000000 ? 163085937 500000000 ? 162597656 500000000 ? 162353515 500000000 ? 162231445 500000000 ? 162292...
result:
ok ok (1000 test cases)
Test #25:
score: 0
Accepted
time: 34ms
memory: 3840kb
input:
1000 999999999 487015083 487015084 487015082 249999935 362015083 299515083 268265083 252640083 244827583 246093685 244140560 243851021 243652278 243606881 243530207 243545846 243515329 243514948 243507700 243511133 243509225 243508271 243507794 243507556 243507581 243507522 243507526 243507511 24350...
output:
? 1 500000000 ? 2 500000000 ? 999999999 500000000 ? 750000000 500000000 ? 875000000 500000000 ? 812500000 500000000 ? 781250000 500000000 ? 765625000 500000000 ? 757812500 500000000 ? 753906250 500000000 ? 755859375 500000000 ? 756835938 500000000 ? 756347657 500000000 ? 756591798 500000000 ? 756469...
result:
ok ok (1000 test cases)
Test #26:
score: 0
Accepted
time: 31ms
memory: 3712kb
input:
1000 999999999 265285129 265285128 250000000 374264884 311764884 280514884 264889884 257472630 260983634 259030509 258053946 257565665 257321524 257350560 257289525 257291006 257275747 257281896 257278082 257276175 257275221 257275270 257275031 257275102 257275043 257275013 257275016 257275008 25727...
output:
? 1 500000000 ? 2 500000000 ? 250000000 500000000 ? 125000000 500000000 ? 62500000 500000000 ? 31250000 500000000 ? 15625000 500000000 ? 7812500 500000000 ? 11718750 500000000 ? 9765625 500000000 ? 8789062 500000000 ? 8300781 500000000 ? 8056640 500000000 ? 7934570 500000000 ? 7995605 500000000 ? 80...
result:
ok ok (1000 test cases)
Test #27:
score: 0
Accepted
time: 39ms
memory: 3840kb
input:
1000 536870912 261621269 261621270 261621268 127403541 67108864 93849109 77071893 75497472 79691776 78290725 77242149 76717861 76809749 76678677 76652325 76645909 76635941 76637717 76633621 76633893 76632869 76633109 76632853 76632741 76632789 76632757 76632741 76632733 76632737 76632735 76632734 76...
output:
? 1 268435457 ? 2 268435457 ? 536870912 268435457 ? 402653185 268435457 ? 335544321 268435457 ? 369098753 268435457 ? 352321537 268435457 ? 343932929 268435457 ? 348127233 268435457 ? 350224385 268435457 ? 351272961 268435457 ? 351797249 268435457 ? 352059393 268435457 ? 351928321 268435457 ? 351862...
result:
ok ok (1000 test cases)
Test #28:
score: 0
Accepted
time: 49ms
memory: 3712kb
input:
1000 536870911 244408485 244408486 244408484 134217728 182757403 210854053 194076837 185688229 181493925 180660251 180445349 180135963 180183205 180052133 180070427 180037659 180035749 180029467 180031653 180029605 180028581 180028955 180028699 180028571 180028517 180028539 180028523 180028515 18002...
output:
? 1 268435456 ? 2 268435456 ? 536870911 268435456 ? 402653184 268435456 ? 469762048 268435456 ? 503316480 268435456 ? 486539264 268435456 ? 478150656 268435456 ? 473956352 268435456 ? 471859200 268435456 ? 472907776 268435456 ? 472383488 268435456 ? 472645632 268435456 ? 472514560 268435456 ? 472449...
result:
ok ok (1000 test cases)
Extra Test:
score: 0
Extra Test Passed