QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#853639 | #9734. Identify Chord | ucup-team159# | AC ✓ | 80ms | 3944kb | C++20 | 7.6kb | 2025-01-11 17:56:01 | 2025-01-11 17:56:07 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < (t); ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define pob pop_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define newline puts("")
#define vc vector
using namespace std;
template<class T> using vv = vc<vc<T>>;
template<class T> using PQ = priority_queue<T,vc<T>,greater<T>>;
using uint = unsigned; using ull = unsigned long long;
using vi = vc<int>; using vvi = vv<int>; using vvvi = vv<vi>;
using ll = long long; using vl = vc<ll>; using vvl = vv<ll>; using vvvl = vv<vl>;
using P = pair<int,int>; using vp = vc<P>; using vvp = vv<P>; using LP = pair<ll,ll>;
int geti(){int x;scanf("%d",&x);return x;}
vi pm(int n, int s=0) { vi a(n); iota(rng(a),s); return a;}
template<class T1,class T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<class T1,class T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<class T>istream& operator>>(istream&i,vc<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<class T>string join(const T&v,const string&d=""){stringstream s;rep(i,sz(v))(i?s<<d:s)<<v[i];return s.str();}
template<class T>ostream& operator<<(ostream&o,const vc<T>&v){if(sz(v))o<<join(v," ");return o;}
template<class T>void vin(vc<T>&a){int n;cin>>n;a=vc<T>(n);cin>>a;}
template<class T>void vin(vv<T>&a){int n,m;cin>>n>>m;a=vv<T>(n,vc<T>(m));cin>>a;}
template<class T1,class T2>void operator--(pair<T1,T2>&a,int){a.fi--;a.se--;}
template<class T1,class T2>void operator++(pair<T1,T2>&a,int){a.fi++;a.se++;}
template<class T>void operator--(vc<T>&a,int){for(T&x:a)x--;}
template<class T>void operator++(vc<T>&a,int){for(T&x:a)x++;}
template<class T1,class T2>void operator+=(vc<T1>&a,T2 b){for(T1&x:a)x+=b;}
template<class T1,class T2>void operator-=(vc<T1>&a,T2 b){for(T1&x:a)x-=b;}
template<class T1,class T2>void operator*=(vc<T1>&a,T2 b){for(T1&x:a)x*=b;}
template<class T1,class T2>void operator/=(vc<T1>&a,T2 b){for(T1&x:a)x/=b;}
template<class T>void operator+=(vc<T>&a,const vc<T>&b){a.insert(a.end(),rng(b));}
template<class T1,class T2>pair<T1,T2>operator+(const pair<T1,T2>&a,const pair<T1,T2>&b){return {a.fi+b.fi,a.se+b.se};}
template<class T1,class T2>pair<T1,T2>operator-(const pair<T1,T2>&a,const pair<T1,T2>&b){return {a.fi-b.fi,a.se-b.se};}
template<class T>pair<T,T>operator*(const pair<T,T>&a,T b){return {a.fi*b,a.se*b};}
template<class T1,class T2>bool mins(T1& x,const T2&y){if(y<x){x=y;return true;}else return false;}
template<class T1,class T2>bool maxs(T1& x,const T2&y){if(x<y){x=y;return true;}else return false;}
template<class T>T min(const vc<T>&a){return *min_element(rng(a));}
template<class T>T max(const vc<T>&a){return *max_element(rng(a));}
template<class Tx,class Ty>Tx dup(Tx x, Ty y){return (x+y-1)/y;}
template<class T>ll suma(const vc<T>&a){ll s=0;for(auto&&x:a)s+=x;return s;}
template<class T>ll suma(const vv<T>&a){ll s=0;for(auto&&x:a)s+=suma(x);return s;}
template<class T>void uni(T&a){sort(rng(a));a.erase(unique(rng(a)),a.end());}
template<class T>void prepend(vc<T>&a,const T&x){a.insert(a.begin(),x);}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return;}
#define yes { puts("Yes"); return;}
#define no { puts("No"); return;}
#define rtn(x) { cout<<(x)<<'\n'; return;} // flush!
#define yn {puts("Yes");}else{puts("No");}
template<class F> ll bis(ll ac, ll wa, F f) {
while (abs(ac-wa)>1) { ll wj=(ac+wa)/2; (f(wj)?ac:wa)=wj;} return ac;
}
template<class F> ll bis2(F f) { // 0:true -> max true
ll r = 1; while (f(r)) r <<= 1; return bis(r>>1,r,f);
}
random_device _rd;
struct xrand {
static const uint64_t _x = 88172645463325252ull;
uint64_t x;
xrand(): x(_x ^ (_rd()+time(0))) {}
xrand(uint64_t seed): x(_x ^ seed) {}
uint64_t get() {
x = x ^ (x << 7);
return x = x ^ (x >> 9);
}
ull operator()() { return get();}
ull operator()(ull n) { return get()%n;}
ll operator()(ll l, ll r) { return get()%(r-l+1) + l;}
} rnd;
template<typename T> void shuffle(vc<T>& a) {
for (int i = a.size(); i >= 2; --i) swap(a[i-1],a[rnd(i)]);
}
// #define TEST
struct Solver {
void solve() {
int N;
#ifdef TEST
int nl = 1<<rnd(2,29), nr = nl<<1;
mins(nl,int(1e9)); mins(nr,int(1e9));
N = rnd(nl,nr);
int wl = 1<<rnd(1,29), wr = wl<<1;
mins(wl,N-2); mins(wr,N-2);
int A = rnd(1,N), w = rnd(wl,wr);
int B = (A-1+w)%N+1;
cerr<<"N: "<<" "<<N<<endl;
cerr<<"answer: "<<" "<<A<<" "<<B<<endl;
#else
cin>>N;
#endif
auto dist = [&](int a, int b) { return min(abs(a-b),N-abs(a-b));};
int CNT = 40;
auto fix = [&](int a) {
return (a%N+N)%N + 1;
};
map<P,int> memo;
auto f = [&](int a, int b) {
a = fix(a); b = fix(b);
if (a > b) swap(a,b);
if (memo.count(P(a,b))) return memo[P(a,b)];
CNT--; assert(CNT >= 0);
cout<<"? "<<a<<" "<<b<<endl;
int d;
#ifdef TEST
d = dist(a,b);
mins(d, dist(A,a)+1+dist(B,b));
mins(d, dist(A,b)+1+dist(B,a));
cerr<<"-> "<<d<<endl;
#else
cin>>d;
#endif
return memo[P(a,b)] = d;
};
auto answer = [&](int a, int b) {
a = fix(a); b = fix(b);
if (a > b) swap(a,b);
cout<<"! "<<a<<" "<<b<<endl;
#ifdef TEST
assert(P(a,b) == P(A,B) || P(b,a) == P(A,B));
#else
int correct;
cin>>correct;
#endif
};
int n = N/2;
auto same = [&](int a, int b) {
// cerr<<"same "<<a<<' '<<b<<endl;
int d = f(a,b);
auto g = [&](int w) {
return (f(a+w,b) == d-w);
};
int nw = bis(0,n,g);
a += nw; d = f(a,b);
b -= (d-1);
answer(a,b);
};
auto opo = [&](int a, int b) {
// cerr<<"opo "<<a<<' '<<b<<endl;
int d = f(a,b);
int sg = (d<=f(a+1,b+1))?-1:1;
auto g = [&](int w) {
int nd = f(a+w*sg,b+w*sg);
return nd == d-2*w;
};
int nw = bis(0,n,g);
a += nw*sg; b += nw*sg; d = f(a,b);
// a or b is correct
d--;
if (dist(a,b+d) != 1 && f(a,b+d) == 1) answer(a,b+d);
else if (dist(a,b-d) != 1 && f(a,b-d) == 1) answer(a,b-d);
else if (dist(a+d,b) != 1 && f(a+d,b) == 1) answer(a+d,b);
else answer(a-d,b);
};
if (N%2 == 0) {
int a = 0, b = n, d = f(a,b);
while (d == n) a++, b++, d = f(a,b);
if (d == f(a+1,b+1)) { // same side
if (f(a+1,b) >= d) swap(a,b);
same(a,b);
} else { // opo
opo(a,b);
}
} else {
int a = 0, b = n, d1 = f(a,b), d2 = f(a,b+1);
while (d1 == n && d2 == n) {
b++; swap(a,b); d2 = f(a,b+1);
}
if (d1 == n || d2 == n) {
if (d1 == n) {
if (f(a+1,b+1) == n) same(b,a);
else opo(a,b);
} else {
b++;
if (f(a-1,b-1) == n) same(a,b);
else opo(a,b);
}
} else {
if (f(a+1,b+1) == d1) {
if (f(a+1,b) >= d1) swap(a,b);
same(a,b);
} else {
opo(a,b);
}
}
}
}
};
int main() {
// cin.tie(nullptr); ios::sync_with_stdio(false);
int ts = 1;
cin>>ts;
rep1(ti,ts) {
Solver solver;
solver.solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
input:
2 6 2 2 1 1 1 4 1 2 1
output:
? 1 4 ? 2 5 ? 2 4 ? 3 4 ! 2 4 ? 1 3 ? 2 4 ! 1 3
result:
ok ok (2 test cases)
Test #2:
score: 0
Accepted
time: 10ms
memory: 3680kb
input:
1000 15 5 6 5 4 2 2 1 1 19 5 4 3 5 1 3 1 17 5 4 3 5 1 3 1 15 6 7 7 5 7 1 14 5 5 4 4 5 1 15 3 2 1 5 3 1 17 8 8 8 7 6 2 4 2 1 1 20 6 8 6 6 6 5 1 1 13 5 6 4 6 2 2 3 3 3 1 18 3 3 4 5 3 2 1 13 4 3 4 5 3 2 1 14 2 4 6 2 3 3 3 1 17 8 7 6 4 4 4 6 5 1 1 12 5 3 3 1 1 10 5 5 3 3 2 1 2 1 14 6 6 5 3 1 1 1 19 8 7 ...
output:
? 1 8 ? 1 9 ? 2 9 ? 2 8 ? 4 8 ? 6 8 ? 5 8 ! 5 8 ? 1 10 ? 1 11 ? 2 11 ? 5 14 ? 3 12 ? 4 13 ! 3 12 ? 1 9 ? 1 10 ? 2 10 ? 5 13 ? 3 11 ? 4 12 ! 3 11 ? 1 8 ? 1 9 ? 8 15 ? 4 9 ? 2 9 ! 1 3 ? 1 8 ? 2 9 ? 2 8 ? 4 8 ? 3 8 ! 2 5 ? 1 8 ? 1 9 ? 2 9 ? 4 11 ? 3 10 ! 2 9 ? 1 9 ? 1 10 ? 2 10 ? 2 11 ? 3 11 ? 6 14 ? 4...
result:
ok ok (1000 test cases)
Test #3:
score: 0
Accepted
time: 28ms
memory: 3676kb
input:
1000 21 3 4 5 9 3 1 1 22 8 6 4 4 4 1 1 20 5 5 4 2 3 2 1 1 22 10 8 4 6 4 4 7 7 1 1 21 9 8 7 5 5 5 7 6 1 1 21 8 7 8 9 5 6 5 4 1 24 11 12 5 5 5 8 8 8 1 22 10 10 10 6 9 9 1 21 4 3 2 8 2 1 1 23 8 7 8 9 3 4 2 3 1 21 10 10 10 9 8 4 6 4 4 7 7 1 1 24 9 7 7 7 7 6 6 1 1 20 9 10 9 9 9 2 2 2 1 24 11 11 10 5 2 2 ...
output:
? 1 11 ? 1 12 ? 2 12 ? 6 17 ? 9 20 ? 10 21 ! 10 21 ? 1 12 ? 2 13 ? 6 17 ? 3 14 ? 4 15 ? 3 17 ! 3 17 ? 1 11 ? 2 12 ? 2 11 ? 6 11 ? 3 11 ? 4 11 ? 5 11 ! 5 11 ? 1 12 ? 2 13 ? 6 17 ? 3 14 ? 4 15 ? 5 16 ? 4 18 ? 4 12 ? 7 15 ! 7 15 ? 1 11 ? 1 12 ? 2 12 ? 6 16 ? 3 13 ? 4 14 ? 3 17 ? 3 9 ? 7 13 ! 7 13 ? 1 1...
result:
ok ok (1000 test cases)
Test #4:
score: 0
Accepted
time: 10ms
memory: 3680kb
input:
1000 25 8 9 10 8 8 8 6 1 1 25 6 7 8 8 4 4 4 7 1 1 25 11 12 10 12 6 6 6 7 1 1 25 5 6 5 4 6 4 3 1 26 12 12 12 7 9 8 8 1 26 11 13 7 7 9 7 7 1 1 26 13 13 11 11 12 5 2 2 1 1 27 12 13 13 7 5 6 6 1 25 9 10 11 9 9 9 5 4 4 1 27 9 10 9 8 7 6 7 1 27 11 10 11 12 8 8 9 1 27 13 13 13 13 12 11 1 7 3 1 26 5 5 6 7 4...
output:
? 1 13 ? 1 14 ? 2 14 ? 7 20 ? 10 23 ? 12 25 ? 1 20 ? 1 6 ! 1 6 ? 1 13 ? 1 14 ? 2 14 ? 7 20 ? 10 23 ? 12 25 ? 11 24 ? 15 25 ? 9 25 ! 9 25 ? 1 13 ? 1 14 ? 13 25 ? 2 15 ? 8 20 ? 11 23 ? 10 22 ? 16 23 ? 6 23 ! 6 23 ? 1 13 ? 1 14 ? 2 14 ? 2 13 ? 7 13 ? 4 13 ? 3 13 ! 3 11 ? 1 14 ? 2 15 ? 2 14 ? 1 20 ? 1 1...
result:
ok ok (1000 test cases)
Test #5:
score: 0
Accepted
time: 12ms
memory: 3684kb
input:
1000 29 10 9 8 6 6 6 1 1 28 13 14 3 7 3 3 5 1 1 30 3 1 13 5 3 1 29 4 5 4 3 7 5 4 1 28 8 10 8 6 6 6 9 9 9 1 29 6 5 4 10 2 2 1 1 29 9 8 9 10 6 6 4 5 1 28 11 11 10 4 4 5 1 30 4 6 12 4 4 7 7 7 1 30 8 10 8 6 6 6 10 10 10 1 28 11 9 9 9 9 6 6 1 1 29 14 13 14 8 11 9 9 1 29 11 12 11 10 7 10 9 1 29 7 8 9 9 7 ...
output:
? 1 15 ? 1 16 ? 2 16 ? 8 22 ? 4 18 ? 3 17 ? 3 22 ! 3 22 ? 1 15 ? 2 16 ? 8 22 ? 12 26 ? 10 24 ? 9 23 ? 12 24 ? 8 24 ! 8 24 ? 1 16 ? 2 17 ? 8 23 ? 4 19 ? 3 18 ! 2 17 ? 1 15 ? 1 16 ? 2 16 ? 2 15 ? 8 15 ? 4 15 ? 3 15 ! 2 13 ? 1 15 ? 2 16 ? 8 22 ? 12 26 ? 14 28 ? 13 27 ? 19 28 ? 9 28 ? 5 14 ! 14 23 ? 1 1...
result:
ok ok (1000 test cases)
Test #6:
score: 0
Accepted
time: 24ms
memory: 3680kb
input:
1000 32 13 13 12 8 9 10 10 1 30 14 14 14 7 4 5 4 1 32 16 16 14 12 4 6 2 2 1 1 31 5 6 5 4 6 2 4 3 1 32 7 5 11 3 3 3 1 1 32 8 6 10 6 6 1 1 31 15 14 13 9 9 9 9 8 7 1 1 31 6 5 6 7 5 3 3 2 1 32 12 12 11 4 4 4 3 1 30 14 14 14 7 4 6 6 1 31 11 12 13 5 5 5 5 9 1 1 31 10 9 10 11 9 11 10 1 33 7 8 9 11 7 7 7 11...
output:
? 1 17 ? 2 18 ? 2 17 ? 9 17 ? 5 17 ? 7 17 ? 6 17 ! 5 9 ? 1 16 ? 2 17 ? 2 16 ? 1 23 ? 1 27 ? 1 25 ? 1 26 ! 26 28 ? 1 17 ? 2 18 ? 3 19 ? 4 20 ? 11 27 ? 7 23 ? 9 25 ? 10 26 ? 9 26 ! 9 26 ? 1 16 ? 1 17 ? 2 17 ? 2 16 ? 8 16 ? 4 16 ? 6 16 ? 5 16 ! 4 15 ? 1 17 ? 2 18 ? 9 25 ? 5 21 ? 3 19 ? 4 20 ? 3 21 ! 3 ...
result:
ok ok (1000 test cases)
Test #7:
score: 0
Accepted
time: 22ms
memory: 3632kb
input:
1000 34 17 16 14 10 10 12 10 1 1 33 8 9 8 7 6 4 4 3 1 33 11 10 11 12 5 7 5 4 1 34 11 13 7 5 7 5 9 1 1 34 11 9 9 9 9 1 1 35 14 15 16 14 14 14 14 5 1 1 34 8 10 10 4 4 4 7 1 1 34 14 12 6 6 6 6 1 1 34 16 16 15 9 13 14 13 1 33 9 8 9 10 9 7 7 6 1 33 16 16 16 16 15 16 8 4 2 1 1 34 16 16 16 8 4 2 1 1 1 33 1...
output:
? 1 18 ? 2 19 ? 3 20 ? 10 27 ? 6 23 ? 4 21 ? 5 22 ? 5 31 ! 5 31 ? 1 17 ? 1 18 ? 2 18 ? 2 17 ? 9 17 ? 5 17 ? 7 17 ? 6 17 ! 6 15 ? 1 17 ? 1 18 ? 2 18 ? 2 17 ? 1 25 ? 1 21 ? 1 23 ? 1 24 ! 24 31 ? 1 18 ? 2 19 ? 10 27 ? 14 31 ? 16 33 ? 15 32 ? 19 32 ? 11 32 ! 11 32 ? 1 18 ? 2 19 ? 9 26 ? 5 22 ? 3 20 ? 2 ...
result:
ok ok (1000 test cases)
Test #8:
score: 0
Accepted
time: 16ms
memory: 3628kb
input:
1000 36 18 17 17 16 8 4 2 1 1 1 36 3 5 17 7 3 3 5 5 5 1 36 13 13 12 9 11 11 10 1 36 5 5 4 9 5 3 4 1 36 18 17 15 9 9 9 9 1 1 36 12 10 8 8 8 8 11 11 1 1 35 13 12 13 14 10 9 11 10 1 36 13 11 9 9 9 9 10 10 1 1 36 14 12 6 6 4 4 1 1 36 16 16 15 9 12 10 9 8 1 36 9 7 11 1 5 3 1 36 8 10 12 2 4 2 3 1 1 36 17 ...
output:
? 1 19 ? 2 20 ? 3 21 ? 3 20 ? 11 20 ? 15 20 ? 17 20 ? 18 20 ? 19 20 ! 18 20 ? 1 19 ? 2 20 ? 10 28 ? 15 33 ? 17 35 ? 18 36 ? 1 21 ? 1 17 ? 3 19 ! 19 35 ? 1 19 ? 2 20 ? 2 19 ? 10 19 ? 5 19 ? 3 19 ? 4 19 ! 4 10 ? 1 19 ? 2 20 ? 2 19 ? 10 19 ? 5 19 ? 3 19 ? 4 19 ! 3 17 ? 1 19 ? 2 20 ? 3 21 ? 11 29 ? 6 24...
result:
ok ok (1000 test cases)
Test #9:
score: 0
Accepted
time: 17ms
memory: 3848kb
input:
1000 37 17 18 16 18 6 10 6 6 11 11 11 1 36 17 17 17 9 13 11 10 10 1 38 9 9 8 6 5 3 4 1 37 15 14 13 11 11 11 11 9 8 1 1 37 12 13 14 12 12 12 12 8 7 7 1 36 8 8 9 9 4 6 5 1 37 6 5 6 7 9 4 4 3 1 37 18 18 18 18 17 16 2 10 6 4 2 3 3 1 1 37 17 18 16 18 16 16 16 3 4 4 1 37 8 7 6 12 4 4 4 7 7 1 1 37 10 9 10 ...
output:
? 1 19 ? 1 20 ? 19 37 ? 2 21 ? 11 29 ? 16 34 ? 14 32 ? 13 31 ? 19 32 ? 9 32 ? 14 37 ! 14 27 ? 1 19 ? 2 20 ? 2 19 ? 1 28 ? 1 23 ? 1 25 ? 1 26 ? 1 27 ! 26 28 ? 1 20 ? 2 21 ? 2 20 ? 10 20 ? 5 20 ? 7 20 ? 8 20 ! 7 18 ? 1 19 ? 1 20 ? 2 20 ? 10 28 ? 5 23 ? 3 21 ? 4 22 ? 3 31 ? 3 11 ? 13 21 ! 13 21 ? 1 19 ...
result:
ok ok (1000 test cases)
Test #10:
score: 0
Accepted
time: 13ms
memory: 3848kb
input:
1000 39 18 17 16 8 10 8 8 13 12 1 1 38 8 8 9 10 10 8 7 1 38 19 19 17 15 9 9 9 9 11 11 1 1 39 12 13 12 11 10 14 12 1 38 15 15 16 10 15 15 14 1 39 4 3 4 5 7 2 2 1 1 39 18 19 17 19 15 15 15 15 5 1 1 38 18 18 17 9 4 2 1 1 1 39 14 13 14 15 5 2 3 2 1 1 39 11 12 11 10 6 7 5 4 5 1 39 9 8 7 11 5 5 5 1 1 38 1...
output:
? 1 20 ? 1 21 ? 2 21 ? 10 29 ? 5 24 ? 7 26 ? 6 25 ? 6 32 ? 6 18 ? 13 25 ! 13 25 ? 1 20 ? 2 21 ? 2 20 ? 1 29 ? 1 24 ? 1 22 ? 1 21 ! 21 33 ? 1 20 ? 2 21 ? 3 22 ? 4 23 ? 12 31 ? 7 26 ? 9 28 ? 8 27 ? 7 34 ? 7 18 ? 15 26 ! 15 26 ? 1 20 ? 1 21 ? 2 21 ? 2 20 ? 10 20 ? 5 20 ? 3 20 ! 2 10 ? 1 20 ? 2 21 ? 2 2...
result:
ok ok (1000 test cases)
Test #11:
score: 0
Accepted
time: 25ms
memory: 3680kb
input:
1000 40 12 10 10 2 4 2 3 3 1 1 40 18 16 6 8 6 6 11 11 1 1 40 15 13 11 11 11 11 1 1 40 8 10 14 8 8 8 13 1 1 40 16 16 17 10 15 14 15 1 40 15 17 7 5 3 3 5 5 5 1 41 13 14 15 13 13 13 13 9 1 1 40 7 7 8 10 6 5 4 5 1 40 18 18 19 10 15 16 17 1 40 6 6 5 10 5 4 3 4 1 40 4 4 3 10 7 4 1 41 12 11 10 10 6 8 6 6 1...
output:
? 1 21 ? 2 22 ? 11 31 ? 6 26 ? 8 28 ? 7 27 ? 6 27 ? 6 25 ? 7 26 ! 7 26 ? 1 21 ? 2 22 ? 11 31 ? 6 26 ? 8 28 ? 7 27 ? 7 32 ? 7 22 ? 12 27 ! 12 27 ? 1 21 ? 2 22 ? 11 31 ? 6 26 ? 3 23 ? 4 24 ? 3 33 ! 3 33 ? 1 21 ? 2 22 ? 11 31 ? 16 36 ? 19 39 ? 20 40 ? 1 28 ? 1 14 ! 1 14 ? 1 21 ? 2 22 ? 2 21 ? 1 31 ? 1 ...
result:
ok ok (1000 test cases)
Test #12:
score: 0
Accepted
time: 24ms
memory: 3684kb
input:
1000 42 11 11 10 11 6 8 7 1 41 17 16 17 18 7 6 5 6 1 41 8 9 10 14 4 4 4 7 1 1 41 12 13 14 10 2 4 2 3 3 3 1 41 12 11 10 10 8 8 8 14 13 1 1 41 18 19 20 8 8 8 8 14 1 1 41 14 13 14 15 4 5 2 3 1 41 20 20 19 18 2 10 6 4 2 1 1 41 17 18 19 9 9 13 11 9 13 1 1 41 15 14 15 16 11 14 13 12 13 1 41 18 19 20 4 8 4...
output:
? 1 22 ? 2 23 ? 2 22 ? 11 22 ? 6 22 ? 8 22 ? 7 22 ! 6 17 ? 1 21 ? 1 22 ? 2 22 ? 2 21 ? 1 31 ? 1 36 ? 1 33 ? 1 34 ! 33 38 ? 1 21 ? 1 22 ? 2 22 ? 11 32 ? 16 37 ? 19 40 ? 18 39 ? 22 40 ? 16 40 ! 16 40 ? 1 21 ? 1 22 ? 2 22 ? 11 32 ? 16 37 ? 14 35 ? 15 36 ? 17 37 ? 15 37 ? 16 38 ! 16 36 ? 1 21 ? 1 22 ? 2...
result:
ok ok (1000 test cases)
Test #13:
score: 0
Accepted
time: 6ms
memory: 3748kb
input:
1000 43 4 5 4 3 10 5 2 3 1 42 18 18 17 8 3 3 4 1 43 6 7 6 5 8 3 4 3 2 1 43 18 19 20 4 8 4 2 2 3 3 3 1 43 21 21 21 20 19 15 15 17 15 15 1 1 43 17 18 19 7 7 7 7 13 1 1 43 18 19 18 17 11 16 16 17 1 43 21 21 21 20 21 11 6 3 2 1 1 42 13 13 14 11 8 8 7 1 42 20 20 20 11 15 13 12 11 1 42 5 7 17 7 1 3 1 43 5...
output:
? 1 22 ? 1 23 ? 2 23 ? 2 22 ? 11 22 ? 6 22 ? 3 22 ? 4 22 ! 3 21 ? 1 22 ? 2 23 ? 2 22 ? 11 22 ? 16 22 ? 19 22 ? 17 22 ! 16 20 ? 1 22 ? 1 23 ? 2 23 ? 2 22 ? 11 22 ? 6 22 ? 3 22 ? 4 22 ? 5 22 ! 5 21 ? 1 22 ? 1 23 ? 2 23 ? 12 34 ? 17 39 ? 15 37 ? 14 36 ? 13 35 ? 15 36 ? 13 36 ? 14 37 ! 14 35 ? 1 22 ? 1 ...
result:
ok ok (1000 test cases)
Test #14:
score: 0
Accepted
time: 20ms
memory: 3916kb
input:
1000 44 22 22 20 18 14 14 16 14 14 1 1 44 11 9 13 3 7 5 3 1 1 43 11 10 11 12 12 12 9 10 1 43 21 21 21 21 20 19 13 13 17 15 13 1 1 44 19 17 17 17 17 1 1 44 16 16 15 11 13 14 13 12 1 44 17 19 13 13 13 13 10 10 10 1 44 10 8 14 6 6 6 11 11 1 1 43 13 14 15 9 9 9 9 14 13 13 1 43 4 3 4 5 12 7 4 1 44 9 9 8 ...
output:
? 1 23 ? 2 24 ? 3 25 ? 4 26 ? 14 36 ? 8 30 ? 5 27 ? 6 28 ? 7 29 ? 6 41 ! 6 41 ? 1 23 ? 2 24 ? 12 34 ? 6 28 ? 3 25 ? 4 26 ? 5 27 ? 5 29 ! 5 29 ? 1 22 ? 1 23 ? 2 23 ? 2 22 ? 1 32 ? 1 27 ? 1 24 ? 1 25 ! 24 36 ? 1 22 ? 1 23 ? 2 23 ? 2 24 ? 3 24 ? 3 25 ? 12 34 ? 7 29 ? 4 26 ? 5 27 ? 6 28 ? 18 28 ! 18 28 ...
result:
ok ok (1000 test cases)
Test #15:
score: 0
Accepted
time: 4ms
memory: 3620kb
input:
1000 45 20 21 22 18 18 18 18 6 1 1 45 16 17 18 8 8 12 10 8 15 1 1 45 10 11 10 9 11 7 8 7 6 1 45 15 14 13 9 5 5 5 1 1 45 11 12 11 10 11 14 11 1 45 16 17 18 8 6 2 4 2 3 3 3 1 45 19 18 19 20 12 18 17 16 17 1 45 5 6 7 19 7 3 3 5 5 5 1 44 19 19 20 8 6 9 9 1 45 12 11 12 13 1 6 3 2 1 44 20 20 21 9 6 9 10 1...
output:
? 1 23 ? 1 24 ? 2 24 ? 12 35 ? 18 41 ? 21 44 ? 22 45 ? 39 45 ? 5 45 ! 5 45 ? 1 23 ? 1 24 ? 2 24 ? 12 35 ? 18 41 ? 21 44 ? 20 43 ? 19 42 ? 26 42 ? 12 42 ! 12 42 ? 1 23 ? 1 24 ? 2 24 ? 2 23 ? 12 23 ? 6 23 ? 3 23 ? 4 23 ? 5 23 ! 5 18 ? 1 23 ? 1 24 ? 2 24 ? 12 34 ? 6 28 ? 9 31 ? 7 29 ? 6 32 ! 6 32 ? 1 2...
result:
ok ok (1000 test cases)
Test #16:
score: 0
Accepted
time: 20ms
memory: 3676kb
input:
1000 46 18 16 6 8 4 6 4 7 7 1 1 46 9 7 15 3 5 3 3 1 1 46 22 20 10 12 10 10 10 1 1 46 19 19 18 12 14 15 15 1 46 5 7 19 7 5 5 9 1 1 46 21 19 7 11 7 9 7 13 13 1 1 46 18 16 6 8 6 6 6 11 11 1 1 46 16 14 8 8 12 10 8 15 15 1 1 46 22 22 22 12 18 21 21 1 46 5 3 19 7 3 1 1 45 19 18 19 20 8 7 8 7 1 46 14 16 10...
output:
? 1 24 ? 2 25 ? 12 35 ? 6 29 ? 9 32 ? 7 30 ? 8 31 ? 8 34 ? 8 28 ? 11 31 ! 11 31 ? 1 24 ? 2 25 ? 12 35 ? 6 29 ? 3 26 ? 4 27 ? 5 28 ? 4 29 ! 4 29 ? 1 24 ? 2 25 ? 12 35 ? 6 29 ? 9 32 ? 7 30 ? 8 31 ? 7 39 ! 7 39 ? 1 24 ? 2 25 ? 2 24 ? 12 24 ? 6 24 ? 9 24 ? 7 24 ! 6 11 ? 1 24 ? 2 25 ? 13 36 ? 19 42 ? 22 ...
result:
ok ok (1000 test cases)
Test #17:
score: 0
Accepted
time: 47ms
memory: 3684kb
input:
1000 1000000000 499999999 499999999 499999999 249999999 125000000 187499999 156249999 140624999 132812499 128906249 126953125 127929688 128417968 128173828 128051758 127990723 127960205 127944947 127952577 127956391 127954484 127953530 127953053 127952815 127952696 127952636 127952607 127952621 1279...
output:
? 1 500000001 ? 2 500000002 ? 2 500000001 ? 1 750000001 ? 1 875000001 ? 1 812500001 ? 1 843750001 ? 1 859375001 ? 1 867187501 ? 1 871093751 ? 1 873046876 ? 1 872070313 ? 1 871582032 ? 1 871826172 ? 1 871948242 ? 1 872009277 ? 1 872039795 ? 1 872055054 ? 1 872047424 ? 1 872043609 ? 1 872045516 ? 1 87...
result:
ok ok (1000 test cases)
Test #18:
score: 0
Accepted
time: 80ms
memory: 3676kb
input:
1000 1000000000 499999969 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 9674909...
output:
? 1 500000001 ? 2 500000002 ? 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 5000...
result:
ok ok (1000 test cases)
Test #19:
score: 0
Accepted
time: 61ms
memory: 3620kb
input:
1000 1000000000 474148191 474148189 25851811 224148191 99148191 36648191 5398191 10226811 2414311 1491941 461185 515379 27099 217043 94973 33937 3419 11841 4213 399 1511 557 79 161 43 19 13 3 7 3 1 1 1000000000 479245617 479245619 20754385 229245617 104245617 41745617 10495617 5129385 2683117 122313...
output:
? 1 500000001 ? 2 500000002 ? 250000001 750000001 ? 125000001 625000001 ? 187500001 687500001 ? 218750001 718750001 ? 234375001 734375001 ? 242187501 742187501 ? 238281251 738281251 ? 236328126 736328126 ? 237304688 737304688 ? 236816407 736816407 ? 237060547 737060547 ? 237182617 737182617 ? 237121...
result:
ok ok (1000 test cases)
Test #20:
score: 0
Accepted
time: 42ms
memory: 3716kb
input:
1000 1000000000 230485382 230485384 269514620 19514620 105485382 42985382 11735382 3889620 3922882 16632 1936494 959932 471650 227510 105440 44404 13886 1374 6256 2442 534 422 72 184 72 126 96 82 74 72 72 143 143 143 1 1000000000 237329401 237329399 262670601 12670601 112329401 49829401 18579401 295...
output:
? 1 500000001 ? 2 500000002 ? 250000001 750000001 ? 375000001 875000001 ? 437500001 937500001 ? 406250001 906250001 ? 390625001 890625001 ? 382812501 882812501 ? 386718751 886718751 ? 384765626 884765626 ? 383789064 883789064 ? 384277345 884277345 ? 384521486 884521486 ? 384643556 884643556 ? 384704...
result:
ok ok (1000 test cases)
Test #21:
score: 0
Accepted
time: 75ms
memory: 3944kb
input:
1000 1000000000 288090905 288090905 288090906 45653197 163090905 100590905 69340905 53715905 45903405 41997155 43700072 42723509 42235228 41991087 41875085 41930052 41899534 41884275 41876646 41872831 41873178 41872225 41872354 41872115 41872106 41872055 41872077 41872062 41872055 41872051 41872053 ...
output:
? 1 500000001 ? 2 500000002 ? 2 500000001 ? 1 750000001 ? 1 625000001 ? 1 687500001 ? 1 718750001 ? 1 734375001 ? 1 742187501 ? 1 746093751 ? 1 748046876 ? 1 747070313 ? 1 746582032 ? 1 746337891 ? 1 746215821 ? 1 746276856 ? 1 746246338 ? 1 746231079 ? 1 746223450 ? 1 746219635 ? 1 746217728 ? 1 74...
result:
ok ok (1000 test cases)
Test #22:
score: 0
Accepted
time: 50ms
memory: 3628kb
input:
1000 999999999 499999998 499999999 499999999 250000001 375000000 312500000 281250001 296875000 289062500 285156250 283203125 282226563 281738282 281494141 281372072 281433106 281402589 281387330 281379702 281383516 281381609 281380656 281381133 281381372 281381490 281381432 281381461 281381447 28138...
output:
? 1 500000000 ? 1 500000001 ? 500000000 999999999 ? 250000000 500000001 ? 125000000 500000001 ? 187500000 500000001 ? 218750000 500000001 ? 203125000 500000001 ? 210937500 500000001 ? 214843750 500000001 ? 216796875 500000001 ? 217773437 500000001 ? 218261718 500000001 ? 218505859 500000001 ? 218627...
result:
ok ok (1000 test cases)
Test #23:
score: 0
Accepted
time: 50ms
memory: 3748kb
input:
1000 999999999 499999957 499999956 499999957 499999958 250000001 374999958 312499958 281250001 296875001 304687501 308593751 310546876 311523439 312011677 311767580 311889607 311828572 311798098 311813357 311820986 311824758 311822894 311823833 311824282 311824044 311823925 311823865 311823835 31182...
output:
? 1 500000000 ? 1 500000001 ? 2 500000001 ? 2 500000000 ? 1 749999999 ? 1 624999999 ? 1 687499999 ? 1 718749999 ? 1 703124999 ? 1 695312499 ? 1 691406249 ? 1 689453124 ? 1 688476561 ? 1 687988280 ? 1 688232420 ? 1 688110350 ? 1 688171385 ? 1 688201902 ? 1 688186643 ? 1 688179014 ? 1 688175199 ? 1 68...
result:
ok ok (1000 test cases)
Test #24:
score: 0
Accepted
time: 67ms
memory: 3680kb
input:
1000 999999999 324545945 324545944 324545943 175454055 74545947 50454055 12045947 19204055 3579055 4233447 327197 1625929 649367 161085 83057 39015 22023 8497 6765 867 2951 1043 89 389 151 31 31 1 15 7 3 1 999999999 446446636 446446635 446446634 53553364 196446638 71446638 8946638 22303364 6678364 1...
output:
? 1 500000000 ? 1 500000001 ? 2 500000001 ? 250000000 749999999 ? 125000000 624999999 ? 187500000 687499999 ? 156250000 656249999 ? 171875000 671874999 ? 164062500 664062499 ? 160156250 660156249 ? 162109375 662109374 ? 163085937 663085936 ? 162597656 662597655 ? 162353515 662353514 ? 162231445 6622...
result:
ok ok (1000 test cases)
Test #25:
score: 0
Accepted
time: 63ms
memory: 3712kb
input:
1000 999999999 487015083 487015084 487015085 12984917 237015085 112015085 49515085 18265085 2640085 5172417 1266167 686961 289603 198681 45461 76611 15577 14943 319 7313 3497 1589 635 159 81 67 67 67 67 67 67 133 133 133 1 999999999 307120211 307120210 307120209 192879789 57120213 67879789 5379789 2...
output:
? 1 500000000 ? 1 500000001 ? 2 500000001 ? 250000001 750000001 ? 375000001 875000001 ? 312500001 812500001 ? 281250001 781250001 ? 265625001 765625001 ? 257812501 757812501 ? 253906251 753906251 ? 255859376 755859376 ? 256835939 756835939 ? 256347658 756347658 ? 256591799 756591799 ? 256469729 7564...
result:
ok ok (1000 test cases)
Test #26:
score: 0
Accepted
time: 78ms
memory: 3684kb
input:
1000 999999999 265285129 265285128 265285127 249264885 249264885 249264885 249264885 249264885 249660131 249264885 249264885 249264885 249264885 249264885 249415991 249293921 249264885 249264885 249278663 249271035 249267221 249265313 249264885 249264885 249265075 249264957 249264897 249264885 24926...
output:
? 1 500000000 ? 1 500000001 ? 2 500000001 ? 250000000 749999999 ? 125000000 624999999 ? 62500000 562499999 ? 31250000 531249999 ? 15625000 515624999 ? 7812500 507812499 ? 11718750 511718749 ? 9765625 509765624 ? 8789062 508789061 ? 8300781 508300780 ? 8056640 508056639 ? 7934570 507934569 ? 7995605 ...
result:
ok ok (1000 test cases)
Test #27:
score: 0
Accepted
time: 63ms
memory: 3692kb
input:
1000 536870912 261621269 261621271 108355805 127403541 108355805 108355805 110626325 108355805 108355805 108529173 108355805 108355805 108355805 108398101 108355805 108365333 108355805 108357141 108355805 108355805 108356117 108355805 108355861 108355805 108355805 108355829 108355813 108355805 10835...
output:
? 1 268435457 ? 2 268435458 ? 134217729 402653185 ? 201326593 469762049 ? 167772161 436207617 ? 184549377 452984833 ? 192937985 461373441 ? 188743681 457179137 ? 190840833 459276289 ? 191889409 460324865 ? 191365121 459800577 ? 191627265 460062721 ? 191758337 460193793 ? 191823873 460259329 ? 191791...
result:
ok ok (1000 test cases)
Test #28:
score: 0
Accepted
time: 57ms
memory: 3624kb
input:
1000 536870911 244408485 244408484 244408485 244408486 110190758 67108865 76636326 68900838 68247718 64706534 66150566 65101990 64577702 64444390 64446630 64381094 64411622 64395238 64387046 64382950 64380902 64380070 64380390 64380134 64380006 64380006 64379974 64379990 64379982 64379978 64379976 6...
output:
? 1 268435456 ? 1 268435457 ? 2 268435457 ? 2 268435456 ? 1 402653183 ? 1 469762047 ? 1 436207615 ? 1 452984831 ? 1 444596223 ? 1 448790527 ? 1 446693375 ? 1 447741951 ? 1 448266239 ? 1 448528383 ? 1 448397311 ? 1 448462847 ? 1 448495615 ? 1 448479231 ? 1 448471039 ? 1 448466943 ? 1 448464895 ? 1 44...
result:
ok ok (1000 test cases)
Extra Test:
score: 0
Extra Test Passed