intmain() { int T; scanf("%d",&T); while (T--) { int n; scanf("%d",&n); int c=1; if (n&1) { int c=1; int now=n-1; int a=2; while (__gcd(a,now)>1) ++a; int b=now-a; printf("%d %d %d\n",a,b,c); } else { int c=1,p=(n-1)/2,q=p+1; printf("%d %d %d\n",p,q,c); } } }
intmain() { int T; scanf("%d",&T); while (T--) { int n; scanf("%d",&n); for (int i=1;i<=n;++i) scanf("%d",a+i); sort(a+1,a+n+1); set<int> s; for (int i=1;i<=n;++i) s.insert(i); bool ok=true; int cnt=0; for (int i=1;i<=n;++i) { if (a[i]<=n && s.count(a[i])) s.erase(a[i]); else { int lim=(a[i]-1)/2; auto p=s.upper_bound(lim); if (p==s.begin()) {ok=false;break;} else --p; ++cnt;s.erase(p); } } printf("%d\n",ok?cnt:-1); } }
intquery(int a,int b,int c) { printf("? %d %d %d\n",a,b,c); fflush(stdout); int x; scanf("%d",&x); return x; }
voidquery(int p,int n,int &a,int &b) { int tmp[4]; int j=(p-1)*3+1; tmp[0]=res[p]; tmp[1]=query(j+1,j+2,j+3); tmp[2]=query(j+2,j+3,j+4); tmp[3]=res[p+1]; for (int i=0;i<3;++i) { if (tmp[i]^tmp[i+1]) { if (tmp[i]==0) a=j+i,b=a+3; else b=j+i,a=b+3; } } return; }
voidquery0(int p,int a,int b) { int i=(p-1)*3+1; int res=query(i,i+1,b); if (res==0) { ans[i]=ans[i+1]=0; ans[i+2]=query(i+2,a,b); } else { ans[i+2]=0; ans[i+1]=query(i+1,a,b); ans[i]=ans[i+1]^1; } }
voidquery1(int p,int a,int b) { int i=(p-1)*3+1; int res=query(i,i+1,a); if (res==1) { ans[i]=ans[i+1]=1; ans[i+2]=query(i+2,a,b); } else { ans[i+2]=1; ans[i+1]=query(i+1,a,b); ans[i]=ans[i+1]^1; } }
voidsolve(int n) { for (int i=1;i<=n/3;++i) res[i]=query((i-1)*3+1,(i-1)*3+2,(i-1)*3+3); int p=0; for (int i=1;i<n/3;++i) if (res[i]^res[i+1]) p=i; int a,b; query(p,n,a,b); // printf("%d %d %d\n",p,a,b); ans[a]=0;ans[b]=1; for (int i=1;i<=n/3;++i) { int L=(i-1)*3+1,R=L+2; if ((L<=a && a<=R) || (L<=b && b<=R)) { for (int i=L;i<=R;++i) if (i!=a && i!=b) ans[i]=query(i,a,b); } else { if (res[i]==0) query0(i,a,b); elsequery1(i,a,b); } } printf("! "); int cnt=0; for (int i=1;i<=n;++i) if (ans[i]==0) ++cnt; printf("%d ",cnt); for (int i=1;i<=n;++i) if (ans[i]==0) printf("%d ",i); putchar('\n'); fflush(stdout); }
intmain() { int T; scanf("%d",&T); while (T--) { int n; scanf("%d",&n); solve(n); } }