QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#727269 | #9570. Binary Tree | ucup-team073# | AC ✓ | 182ms | 15920kb | C++20 | 4.9kb | 2024-11-09 12:22:09 | 2024-11-09 12:22:11 |
Judging History
answer
#include<bits/stdc++.h>
#ifdef LOCAL
#define debug(...) printf(__VA_ARGS__)
#define edebug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#define edebug(...)
#endif
#define int ll
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define nrep(i, x, y) for(int i = x; i >= y; --i)
#define ll long long
#define pii std::pair<int,int>
#define pb emplace_back
#define fi first
#define se second
template <class T>
inline void ckmax(T &a, T b) {
if(a < b) a = b;
}
template <class T>
inline void ckmin(T &a, T b) {
if(a > b) a = b;
}
auto rt_YES = []{puts("YES");};
auto rt_Yes = []{puts("Yes");};
auto rt_NO = []{puts("NO");};
auto rt_No = []{puts("No");};
namespace IO {
#define isdigit(x) (x >= '0' && x <= '9')
inline char gc() {
return getchar();
}
inline bool blank(char ch) {
return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
template <class T>
inline void read(T &x) {
double tmp = 1;
bool sign = 0;
x = 0;
char ch = gc();
for(; !isdigit(ch); ch = gc())
if(ch == '-') sign = 1;
for(; isdigit(ch); ch = gc())
x = x * 10 + (ch - '0');
if(ch == '.')
for(ch = gc(); isdigit(ch); ch = gc())
tmp /= 10.0, x += tmp * (ch - '0');
if(sign) x = -x;
}
inline void read(char *s) {
char ch = gc();
for(; blank(ch); ch = gc());
for(; !blank(ch); ch = gc())
*s++ = ch;
*s = 0;
}
inline void read(char &c) {
for(c = gc(); blank(c); c = gc());
}
inline void push(const char &c) {
putchar(c);
}
template <class T>
inline void print(T x) {
if(x < 0) {
x = -x;
push('-');
}
static T sta[35];
T top = 0;
do {
sta[top++] = x % 10;
x /= 10;
} while(x);
while(top)
push(sta[--top] + '0');
}
template <class T>
inline void print(T x, char lastChar) {
print(x);
push(lastChar);
}
}
using namespace IO;
int l[100010],r[100010],sz[100010],fa[100010],root,vis[100010];
std::vector<int>exist;
int ask(int u,int v){
std::cout<<"? "<<u<<' '<<v<<std::endl;
int ans;read(ans);return ans;
}
void ans(int u){
std::cout<<"! "<<u<<std::endl;
}
void dfs(int u,int f){
fa[u]=f,sz[u]=1;exist.pb(u);
if(l[u])dfs(l[u],u),sz[u]+=sz[l[u]];
if(r[u])dfs(r[u],u),sz[u]+=sz[r[u]];
}
void solve(){
int n;read(n);
rep(i,1,n)vis[i]=0;
rep(i,1,n)read(l[i]),read(r[i]),vis[l[i]]=vis[r[i]]=1;
rep(i,1,n)if(!vis[i])root=i;
while(1){
exist.clear();
if(!l[root]&&!r[root]){ans(root);break;}
dfs(root,0);n=sz[root];
if(n==2){
if(l[root]){
int T=ask(root,l[root]);
if(T==0)ans(root);
else ans(l[root]);
}
else{
int T=ask(root,r[root]);
if(T==0)ans(root);
else ans(r[root]);
}
return;
}
for(int&i:exist){
int szl=0,szr=0,szi=0;
if(l[i])szl=sz[l[i]];
if(r[i])szr=sz[r[i]];
if(!l[i]&&!r[i])continue;
if(!l[i]&&!fa[i])continue;
if(!r[i]&&!fa[i])continue;
if(szl&&std::__lg(szl)==std::__lg(n))continue;
if(szr&&std::__lg(szr)==std::__lg(n))continue;
szi=n-szl-szr-1;
if(szi&&std::__lg(szi)==std::__lg(n))continue;
if(!l[i]){
int T=ask(r[i],fa[i]);
if(T==1){ans(i);return;}
if(T==0){root=r[i];break;}
if(T==2){
if(l[fa[i]]==i)l[fa[i]]=0;
else r[fa[i]]=0;
break;
}
}else if(!r[i]){
int T=ask(l[i],fa[i]);
if(T==1){ans(i);return;}
if(T==0){root=l[i];break;}
if(T==2){
if(l[fa[i]]==i)l[fa[i]]=0;
else r[fa[i]]=0;
break;
}
}else if(std::__lg(szi+1)==std::__lg(n)){
if(szl>szr){
int T=ask(l[i],fa[i]);
if(T==1){
root=i,l[i]=0;
break;
}
if(T==0){root=l[i];break;}
if(T==2){
if(l[fa[i]]==i)l[fa[i]]=0;
else r[fa[i]]=0;
break;
}
}
else{
int T=ask(r[i],fa[i]);
if(T==1){
root=i,r[i]=0;
break;
}
if(T==0){root=r[i];break;}
if(T==2){
if(l[fa[i]]==i)l[fa[i]]=0;
else r[fa[i]]=0;
break;
}
}
}else{
int T=ask(l[i],r[i]);
if(T==0){root=l[i];break;}
if(T==2){root=r[i];break;}
if(T==1){l[i]=r[i]=0;break;}
}
}
for(int&i:exist)sz[i]=0;
}
}
signed main() {
clock_t c1 = clock();
#ifdef LOCAL
// freopen("in.in", "r", stdin);
// freopen("out.out", "w", stdout);
#endif
//------------------------------------------------------------------
int t;read(t);while(t--)solve();
//------------------------------------------------------------------
end:
std::cerr << "Time : " << clock() - c1 << " ms" << std::endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5692kb
input:
2 5 0 0 1 5 2 4 0 0 0 0 0 1 2 0 2 0 0 2
output:
? 2 4 ? 1 5 ! 2 ? 1 2 ! 2
result:
ok OK (2 test cases)
Test #2:
score: 0
Accepted
time: 43ms
memory: 6028kb
input:
5555 8 2 0 8 6 0 0 3 0 0 0 7 0 0 0 5 4 0 2 0 8 0 0 1 4 2 0 0 0 7 8 0 0 3 0 6 0 0 0 1 8 5 8 0 0 1 7 0 0 0 0 4 2 0 0 6 0 0 0 1 5 4 5 3 1 0 0 0 0 0 0 2 0 8 0 0 0 0 5 6 0 0 1 4 2 0 3 8 0 0 0 0 1 5 3 0 5 1 0 0 0 0 4 0 0 2 5 5 0 0 0 0 0 3 0 2 4 2 0 3 3 0 1 0 0 0 2 2 2 0 0 0 2 3 2 3 0 0 0 0 1 10 2 8 9 7 0 ...
output:
? 8 6 ? 5 4 ? 4 3 ! 4 ? 7 8 ? 2 7 ? 1 4 ! 2 ? 1 7 ? 6 1 ? 4 2 ! 6 ? 3 1 ? 4 5 ! 4 ? 3 8 ? 5 6 ? 1 4 ! 5 ? 5 1 ? 5 4 ! 4 ? 2 4 ? 4 3 ! 4 ? 3 2 ! 2 ? 1 2 ! 2 ? 2 3 ! 1 ? 9 7 ? 6 5 ? 4 3 ! 4 ? 1 2 ! 2 ? 3 7 ? 2 1 ? 2 6 ! 2 ? 3 10 ? 4 10 ? 6 2 ! 2 ? 8 2 ? 3 4 ? 6 5 ! 5 ? 2 1 ! 1 ? 3 4 ? 1 7 ! 1 ? 6 2 ? ...
result:
ok OK (5555 test cases)
Test #3:
score: 0
Accepted
time: 19ms
memory: 5752kb
input:
600 2 2 0 0 0 2 3 2 0 3 0 0 0 2 4 4 0 1 0 0 0 3 0 0 0 5 4 0 0 0 1 0 2 0 3 0 0 1 6 4 0 6 0 2 0 5 0 0 0 1 0 0 0 7 7 0 3 0 6 0 5 0 2 0 1 0 0 0 0 1 8 7 0 0 0 2 0 8 0 1 0 5 0 3 0 6 0 0 0 2 9 7 0 4 0 2 0 1 0 0 0 8 0 9 0 5 0 6 0 0 2 2 10 9 0 6 0 8 0 7 0 0 0 10 0 2 0 4 0 5 0 1 0 0 2 2 11 2 0 10 0 6 0 9 0 0 ...
output:
? 1 2 ! 2 ? 3 1 ! 1 ? 4 2 ? 4 3 ! 4 ? 1 5 ? 2 1 ! 4 ? 1 2 ? 5 1 ! 5 ? 6 2 ? 7 6 ! 1 ? 6 4 ? 7 5 ? 2 7 ! 7 ? 4 3 ? 6 7 ? 7 4 ! 4 ? 7 8 ? 1 6 ? 6 7 ! 7 ? 9 11 ? 3 2 ? 5 3 ! 5 ? 6 7 ? 10 1 ? 1 6 ! 1 ? 4 9 ? 12 7 ? 7 4 ! 4 ? 4 13 ? 6 1 ? 1 4 ! 4 ? 2 14 ? 7 4 ? 6 7 ! 6 ? 3 4 ? 8 13 ? 11 16 ? 16 8 ! 8 ? 1...
result:
ok OK (600 test cases)
Test #4:
score: 0
Accepted
time: 55ms
memory: 15920kb
input:
2 99999 21832 0 77205 0 62668 0 58313 0 14640 0 76941 0 62678 0 8464 0 43145 0 26195 0 46140 0 83205 0 40047 0 81645 0 27077 0 92036 0 14236 0 3576 0 15430 0 75654 0 29049 0 62218 0 83318 0 1116 0 77861 0 9755 0 49236 0 70959 0 62295 0 33580 0 88208 0 55840 0 71061 0 24695 0 88831 0 1891 0 57285 0 9...
output:
? 7565 28683 ? 6971 71188 ? 99811 85569 ? 76507 81484 ? 9988 58367 ? 66490 15885 ? 74930 75437 ? 30057 34308 ? 18904 52750 ? 83660 2026 ? 65764 23642 ? 40534 70998 ? 25827 24364 ? 98800 71526 ? 71467 92668 ? 92668 25827 ! 25827 ? 11993 86419 ? 85348 54998 ? 9029 12254 ? 34203 67031 ? 2428 3951 ? 174...
result:
ok OK (2 test cases)
Test #5:
score: 0
Accepted
time: 26ms
memory: 12144kb
input:
15 3 0 0 1 0 2 0 1 7 6 0 3 0 5 0 0 0 7 0 4 0 1 0 2 2 15 6 0 5 0 1 0 7 0 14 0 11 0 15 0 12 0 2 0 4 0 9 0 13 0 0 0 8 0 3 0 0 0 0 31 3 0 31 0 17 0 23 0 4 0 13 0 1 0 12 0 6 0 0 0 20 0 26 0 14 0 29 0 8 0 25 0 21 0 19 0 5 0 15 0 18 0 10 0 22 0 7 0 28 0 2 0 24 0 30 0 27 0 9 0 16 0 2 0 0 2 63 15 0 62 0 5 0 ...
output:
? 1 3 ! 2 ? 1 5 ? 5 2 ! 2 ? 9 6 ? 8 5 ? 13 8 ! 13 ? 29 13 ? 16 2 ? 9 28 ? 13 9 ! 9 ? 8 37 ? 10 24 ? 12 57 ? 46 4 ? 4 8 ! 36 ? 36 89 ? 96 110 ? 79 20 ? 112 121 ? 8 4 ? 20 8 ! 8 ? 64 233 ? 148 51 ? 1 176 ? 78 126 ? 46 136 ? 214 77 ? 126 214 ! 126 ? 439 48 ? 457 144 ? 228 4 ? 328 386 ? 360 120 ? 96 23 ...
result:
ok OK (15 test cases)
Test #6:
score: 0
Accepted
time: 27ms
memory: 12292kb
input:
16 2 2 0 0 0 2 4 4 0 3 0 1 0 0 0 0 0 8 5 0 0 0 4 0 8 0 2 0 3 0 6 0 1 0 0 0 1 16 2 0 5 0 1 0 11 0 13 0 14 0 8 0 6 0 0 0 4 0 3 0 7 0 15 0 10 0 16 0 9 0 0 0 2 0 32 15 0 0 0 14 0 18 0 26 0 17 0 25 0 27 0 6 0 9 0 4 0 13 0 23 0 30 0 32 0 12 0 11 0 31 0 28 0 3 0 19 0 10 0 22 0 7 0 5 0 29 0 24 0 20 0 21 0 1...
output:
? 1 2 ! 2 ? 1 2 ? 1 4 ! 1 ? 3 7 ? 1 4 ? 2 1 ! 5 ? 8 12 ? 1 11 ? 15 5 ? 5 1 ! 5 ? 24 8 ? 13 16 ? 4 17 ? 15 31 ? 2 15 ! 32 ? 30 29 ? 24 8 ? 49 41 ? 54 5 ? 1 64 ? 64 49 ! 49 ? 35 87 ? 124 57 ? 97 61 ? 71 18 ? 122 68 ? 75 40 ? 68 75 ! 68 ? 95 121 ? 3 106 ? 222 91 ? 67 233 ? 231 68 ? 9 190 ? 11 63 ? 63 2...
result:
ok OK (16 test cases)
Test #7:
score: 0
Accepted
time: 27ms
memory: 12396kb
input:
15 2 2 0 0 0 2 6 5 0 1 0 6 0 2 0 3 0 0 0 0 2 14 12 0 0 0 11 0 5 0 7 0 1 0 8 0 10 0 14 0 13 0 6 0 9 0 2 0 4 0 0 0 1 30 10 0 29 0 23 0 28 0 9 0 14 0 2 0 30 0 19 0 0 0 15 0 1 0 22 0 8 0 18 0 27 0 7 0 24 0 26 0 3 0 20 0 25 0 6 0 17 0 4 0 12 0 21 0 16 0 13 0 5 0 0 0 0 2 62 24 0 22 0 18 0 17 0 49 0 53 0 3...
output:
? 1 2 ! 2 ? 5 2 ? 6 5 ! 5 ? 4 9 ? 10 7 ? 2 10 ! 13 ? 21 16 ? 5 8 ? 12 19 ? 10 12 ! 12 ? 60 10 ? 2 9 ? 6 25 ? 16 41 ? 41 6 ! 53 ? 70 84 ? 90 37 ? 75 99 ? 3 105 ? 123 42 ? 42 70 ! 42 ? 12 100 ? 118 71 ? 192 44 ? 92 67 ? 54 221 ? 95 230 ? 230 54 ! 54 ? 359 209 ? 139 137 ? 296 75 ? 357 51 ? 237 269 ? 34...
result:
ok OK (15 test cases)
Test #8:
score: 0
Accepted
time: 14ms
memory: 5764kb
input:
600 2 2 0 0 0 2 3 3 2 0 0 0 0 2 4 3 0 0 0 0 0 1 2 0 0 5 0 0 3 1 4 5 0 0 0 0 0 1 6 3 5 1 4 0 0 6 0 0 0 0 0 0 0 7 3 7 0 0 0 0 2 5 0 0 1 4 0 0 0 1 8 0 0 3 7 1 0 2 5 6 8 0 0 0 0 0 0 0 0 0 9 9 8 0 0 7 2 0 0 0 0 0 0 0 0 4 5 3 6 0 0 2 10 3 6 8 0 4 2 5 7 0 0 10 9 0 0 0 0 0 0 0 0 0 0 2 11 0 0 4 9 5 8 6 3 0 0...
output:
? 1 2 ! 2 ? 3 2 ! 2 ? 1 2 ? 1 3 ! 1 ? 3 1 ? 4 5 ! 3 ? 1 4 ? 3 5 ! 3 ? 1 4 ? 3 7 ! 1 ? 2 5 ? 3 7 ? 3 1 ! 3 ? 9 8 ? 3 6 ? 7 2 ! 2 ? 3 6 ? 4 2 ? 5 7 ! 7 ? 4 9 ? 6 3 ? 5 8 ! 8 ? 6 7 ? 11 5 ? 3 9 ! 3 ? 10 12 ? 7 8 ? 2 1 ! 2 ? 12 11 ? 5 10 ? 2 6 ! 6 ? 8 14 ? 4 9 ? 1 3 ! 9 ? 15 7 ? 9 11 ? 14 6 ? 14 13 ! 14...
result:
ok OK (600 test cases)
Test #9:
score: 0
Accepted
time: 37ms
memory: 8172kb
input:
2 99999 0 0 7999 97267 75750 37659 0 0 0 0 33761 92098 90707 18838 13602 27569 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14586 86647 1519 23132 0 0 3430 14643 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 47066 36968 95308 38482 34100 25297 0 0 0 0 0 0 0 0 88902 58991 0 0 0 0 66315 68538 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
? 4273 79924 ? 69076 22163 ? 92415 75437 ? 65514 14222 ? 97277 31561 ? 98652 69624 ? 81925 96042 ? 73586 14491 ? 93451 76373 ? 26400 6223 ? 11596 13039 ? 98067 19226 ? 76029 67322 ? 87057 15474 ? 33328 72258 ? 3629 77058 ! 77058 ? 28897 96633 ? 78976 42261 ? 49149 4961 ? 4895 41284 ? 23848 71553 ? 3...
result:
ok OK (2 test cases)
Test #10:
score: 0
Accepted
time: 14ms
memory: 7072kb
input:
15 3 3 2 0 0 0 0 1 7 0 0 3 6 0 0 7 2 0 0 0 0 5 1 2 2 15 14 12 0 0 0 0 0 0 8 6 10 11 0 0 3 7 2 4 0 0 0 0 0 0 15 5 0 0 9 1 0 0 0 31 4 9 0 0 29 17 0 0 0 0 15 31 5 21 18 14 0 0 0 0 0 0 16 2 12 7 0 0 23 10 0 0 30 13 0 0 24 27 11 26 0 0 0 0 0 0 0 0 19 20 0 0 0 0 0 0 6 25 8 1 28 22 2 0 0 2 63 53 48 40 57 0...
output:
? 3 2 ! 1 ? 7 2 ? 3 6 ! 6 ? 15 5 ? 9 1 ? 2 4 ! 2 ? 29 17 ? 30 13 ? 8 1 ? 18 14 ! 14 ? 1 2 ? 53 48 ? 63 19 ? 30 56 ? 55 59 ! 56 ? 20 115 ? 71 68 ? 67 3 ? 18 16 ? 123 55 ? 117 104 ! 104 ? 70 140 ? 78 250 ? 223 4 ? 220 204 ? 67 144 ? 75 15 ? 242 199 ! 242 ? 60 121 ? 414 74 ? 99 184 ? 301 403 ? 425 477 ...
result:
ok OK (15 test cases)
Test #11:
score: 0
Accepted
time: 12ms
memory: 7276kb
input:
16 2 0 0 1 0 2 4 4 2 0 0 0 0 3 0 0 0 8 3 0 0 0 0 0 0 0 1 2 0 0 6 4 5 7 0 0 2 16 16 15 0 0 0 0 0 0 7 11 8 10 0 0 13 0 0 0 0 0 0 0 3 9 0 0 4 2 5 14 6 12 0 0 0 0 32 0 0 22 21 25 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 10 30 0 1 24 12 31 0 0 0 0 16 8 3 15 11 26 23 14 28 20 6 9 0 0 13 27 0 0 0 0 7 17 0 0 0 ...
output:
? 2 1 ! 1 ? 4 2 ? 4 3 ! 4 ? 5 7 ? 1 2 ? 1 3 ! 3 ? 16 15 ? 6 12 ? 8 10 ? 8 13 ! 8 ? 19 2 ? 3 15 ? 25 18 ? 13 27 ? 13 30 ! 30 ? 9 14 ? 58 24 ? 29 32 ? 17 3 ? 15 39 ? 15 57 ! 15 ? 92 13 ? 83 73 ? 57 115 ? 62 54 ? 56 55 ? 79 88 ? 79 69 ! 79 ? 245 3 ? 218 134 ? 223 108 ? 47 234 ? 119 200 ? 90 69 ? 135 20...
result:
ok OK (16 test cases)
Test #12:
score: 0
Accepted
time: 14ms
memory: 7288kb
input:
15 2 0 0 1 0 2 6 6 4 1 5 0 0 0 0 3 0 0 0 0 2 14 0 0 1 7 5 11 13 9 0 0 2 8 0 0 10 0 0 0 0 0 0 0 14 6 0 0 3 4 0 0 1 30 7 0 5 13 0 0 0 0 14 30 15 20 0 0 0 0 3 19 0 0 0 0 11 21 9 1 16 24 0 0 0 0 28 2 8 10 0 0 0 0 0 0 0 0 18 6 0 0 4 29 12 25 0 0 23 26 0 0 27 22 0 0 0 2 62 0 0 0 0 28 47 7 38 0 0 0 0 17 26...
output:
? 2 1 ! 1 ? 1 5 ? 6 4 ! 4 ? 14 6 ? 3 4 ? 5 11 ! 3 ? 28 2 ? 23 26 ? 18 6 ? 8 10 ! 10 ? 16 57 ? 36 43 ? 12 4 ? 22 15 ? 11 53 ! 15 ? 18 44 ? 53 93 ? 51 69 ? 28 20 ? 7 27 ? 39 94 ! 39 ? 253 196 ? 42 224 ? 178 31 ? 58 6 ? 14 64 ? 57 160 ? 148 207 ! 207 ? 284 376 ? 30 32 ? 22 406 ? 231 379 ? 464 168 ? 403...
result:
ok OK (15 test cases)
Test #13:
score: 0
Accepted
time: 3ms
memory: 5936kb
input:
600 2 0 0 1 0 2 3 0 0 1 3 0 0 2 4 2 4 0 0 0 0 3 0 2 2 5 2 5 0 0 0 0 0 0 4 3 2 0 6 6 4 0 0 0 0 3 0 2 1 0 0 1 2 7 0 0 0 0 2 4 5 6 0 0 0 0 1 3 1 2 8 2 7 0 0 6 0 0 0 8 3 0 0 4 5 0 0 2 1 2 9 5 2 0 0 7 4 6 8 0 0 0 0 0 0 9 1 0 0 2 2 1 10 3 5 10 7 0 0 0 0 6 2 0 0 4 0 9 1 0 0 0 0 2 1 0 11 9 6 4 1 0 0 0 0 11 ...
output:
? 2 1 ! 1 ? 1 3 ! 3 ? 2 4 ? 4 3 ! 3 ? 2 5 ? 4 3 ! 4 ? 6 4 ? 2 1 ! 1 ? 2 4 ? 1 3 ! 3 ? 2 7 ? 8 3 ? 4 5 ! 5 ? 7 4 ? 9 1 ? 5 2 ! 1 ? 3 5 ? 10 7 ? 6 2 ! 6 ? 9 6 ? 7 5 ? 11 8 ! 11 ? 10 4 ? 6 8 ? 5 1 ! 1 ? 10 8 ? 11 5 ? 3 6 ! 6 ? 9 8 ? 4 12 ? 2 6 ! 2 ? 12 14 ? 10 9 ? 4 6 ! 3 ? 7 2 ? 14 15 ? 13 10 ? 9 6 ! ...
result:
ok OK (600 test cases)
Test #14:
score: 0
Accepted
time: 26ms
memory: 12124kb
input:
2 99999 96748 53986 34197 77552 29863 63559 79099 26449 45078 1051 0 0 27416 4135 0 0 38606 81189 93892 68603 48776 185 79602 18311 51243 83678 89044 40032 28883 35663 0 0 0 0 21603 15821 0 0 51448 75971 70275 8326 0 0 0 0 57049 72937 3297 94939 0 0 59258 39159 3205 34675 54876 24769 0 0 0 0 0 0 851...
output:
? 74980 25670 ? 70516 12118 ? 12933 91439 ? 97212 36694 ? 85790 20519 ? 14682 42183 ? 86482 13659 ? 46078 91113 ? 55007 23588 ? 48007 9719 ? 47589 10242 ? 55947 13113 ? 26123 19657 ? 81729 53038 ? 76338 53869 ? 55526 58545 ! 58545 ? 74467 17532 ? 48883 66572 ? 6758 17942 ? 54390 47563 ? 33872 13481 ...
result:
ok OK (2 test cases)
Test #15:
score: 0
Accepted
time: 13ms
memory: 9492kb
input:
15 3 0 0 1 3 0 0 1 7 0 0 1 7 0 0 6 2 3 4 0 0 0 0 2 2 15 2 11 0 0 13 1 12 14 0 0 0 0 5 8 10 4 0 0 0 0 0 0 0 0 0 0 6 15 9 3 1 1 0 31 24 22 0 0 31 6 0 0 4 3 11 19 0 0 0 0 28 21 25 20 0 0 0 0 0 0 2 16 0 0 27 18 8 10 15 17 26 1 23 29 7 5 12 14 0 0 0 0 0 0 0 0 0 0 0 0 30 13 0 0 0 0 2 1 1 2 63 51 35 33 57 ...
output:
? 1 3 ! 2 ? 6 2 ? 1 7 ! 7 ? 6 15 ? 10 4 ? 5 8 ! 5 ? 12 14 ? 8 10 ? 27 18 ? 2 16 ! 16 ? 15 38 ? 47 22 ? 13 27 ? 29 44 ? 4 32 ! 44 ? 34 51 ? 33 108 ? 124 30 ? 9 27 ? 87 126 ? 73 2 ! 2 ? 83 124 ? 22 162 ? 230 84 ? 112 110 ? 51 147 ? 29 223 ? 117 212 ! 117 ? 460 322 ? 386 146 ? 81 102 ? 473 135 ? 263 27...
result:
ok OK (15 test cases)
Test #16:
score: 0
Accepted
time: 22ms
memory: 9540kb
input:
16 2 0 0 1 0 2 4 0 0 1 0 4 2 0 0 2 2 8 0 0 0 0 0 0 3 5 8 6 2 0 1 4 0 0 2 1 1 16 0 0 7 8 0 0 1 2 0 0 0 0 0 0 5 10 3 0 12 16 14 13 0 0 15 4 0 0 0 0 6 9 2 1 1 2 32 26 17 5 31 28 25 18 7 0 0 0 0 14 12 15 0 22 4 0 0 29 1 19 2 0 0 0 0 0 0 6 8 10 21 0 0 0 0 0 0 13 3 0 0 0 0 0 0 32 30 0 0 20 9 0 0 0 0 23 16...
output:
? 2 1 ! 1 ? 4 2 ? 2 1 ! 1 ? 1 4 ? 8 6 ? 3 5 ! 4 ? 14 13 ? 5 10 ? 1 2 ? 15 4 ! 4 ? 20 9 ? 26 17 ? 19 2 ? 18 7 ? 14 12 ! 7 ? 64 26 ? 29 10 ? 34 60 ? 8 53 ? 24 31 ? 39 56 ! 39 ? 32 9 ? 79 43 ? 99 19 ? 103 69 ? 109 123 ? 4 95 ? 42 113 ! 113 ? 54 173 ? 97 89 ? 22 208 ? 161 94 ? 77 80 ? 213 28 ? 9 150 ? 3...
result:
ok OK (16 test cases)
Test #17:
score: 0
Accepted
time: 15ms
memory: 9708kb
input:
15 2 0 0 1 0 2 6 0 0 5 0 1 2 0 0 0 0 4 3 1 2 14 8 14 0 0 0 0 0 0 0 0 12 11 10 0 0 0 2 7 0 0 4 1 0 0 3 6 5 9 1 1 1 30 29 21 6 9 0 0 0 0 0 0 0 0 0 0 19 17 24 30 0 0 14 26 23 0 0 0 0 0 25 18 0 0 7 20 16 12 0 0 13 11 28 8 10 15 0 0 0 0 0 0 3 22 5 2 0 0 0 0 4 1 1 1 1 2 62 0 0 34 33 0 0 0 0 0 0 37 45 0 0 ...
output:
? 2 1 ! 1 ? 1 2 ? 4 3 ! 3 ? 8 14 ? 12 11 ? 3 6 ! 13 ? 7 20 ? 4 1 ? 6 9 ? 5 2 ! 2 ? 48 42 ? 55 12 ? 20 43 ? 11 58 ? 46 10 ! 58 ? 41 17 ? 104 102 ? 44 110 ? 125 61 ? 83 40 ? 43 76 ! 43 ? 59 90 ? 44 221 ? 63 74 ? 38 228 ? 154 196 ? 104 231 ? 226 53 ! 53 ? 468 192 ? 30 303 ? 346 190 ? 120 241 ? 310 180 ...
result:
ok OK (15 test cases)
Test #18:
score: 0
Accepted
time: 38ms
memory: 8180kb
input:
2 99999 0 0 88119 0 72740 0 6901 19702 0 0 10620 84889 0 0 9552 63972 45156 60768 9152 72379 0 0 59875 97207 48193 0 17282 54916 65927 27713 80083 15817 36966 75381 0 0 77279 56298 0 0 11554 61779 0 0 89976 0 65282 42151 95206 62876 97329 86772 0 0 0 0 0 0 11820 0 0 0 20432 0 50520 39907 0 0 46948 1...
output:
? 26122 52174 ? 57914 41486 ? 63846 21726 ? 93208 82363 ? 21507 88655 ? 22873 65595 ? 31411 65825 ? 12068 56439 ? 44277 38000 ? 50612 98366 ? 8452 20498 ? 73433 14256 ? 42183 48820 ? 59278 42722 ? 36125 55532 ? 79270 29801 ! 42722 ? 91773 80592 ? 68004 50906 ? 73367 20489 ? 49952 83576 ? 77738 33839...
result:
ok OK (2 test cases)
Test #19:
score: 0
Accepted
time: 182ms
memory: 5680kb
input:
100000 2 0 0 0 1 2 2 0 0 0 1 0 2 0 0 0 1 2 2 0 0 0 1 0 2 0 0 0 1 2 2 0 0 0 1 0 2 0 0 0 1 0 2 0 0 0 1 0 2 0 0 0 1 0 2 0 0 0 1 2 2 0 0 0 1 0 2 0 0 0 1 0 2 0 0 0 1 2 2 0 0 0 1 2 2 0 0 0 1 0 2 0 0 0 1 2 2 0 0 0 1 2 2 0 0 0 1 2 2 0 0 0 1 2 2 0 0 0 1 0 2 0 0 0 1 0 2 0 0 0 1 0 2 0 0 0 1 2 2 0 0 0 1 0 2 0 0...
output:
? 2 1 ! 1 ? 2 1 ! 2 ? 2 1 ! 1 ? 2 1 ! 2 ? 2 1 ! 1 ? 2 1 ! 2 ? 2 1 ! 2 ? 2 1 ! 2 ? 2 1 ! 2 ? 2 1 ! 1 ? 2 1 ! 2 ? 2 1 ! 2 ? 2 1 ! 1 ? 2 1 ! 1 ? 2 1 ! 2 ? 2 1 ! 1 ? 2 1 ! 1 ? 2 1 ! 1 ? 2 1 ! 1 ? 2 1 ! 2 ? 2 1 ! 2 ? 2 1 ! 2 ? 2 1 ! 1 ? 2 1 ! 2 ? 2 1 ! 2 ? 2 1 ! 1 ? 2 1 ! 1 ? 2 1 ! 1 ? 2 1 ! 1 ? 2 1 ! 1 ...
result:
ok OK (100000 test cases)
Extra Test:
score: 0
Extra Test Passed