fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define FAST1 ios_base::sync_with_stdio(false);
  5. #define FAST2 cin.tie(NULL);
  6. ll getpos(ll n){
  7. for(ll i=0;i<n-1;i+=2){
  8. ll x;
  9. cout<<"? 1 "<<i+1<<" "<<i+2<<" "<<n-1<<endl;
  10. cin>>x;
  11. if(x==n)
  12. return i+1;
  13. if(x==n-1){
  14. cout<<"? 1 "<<i+2<<" "<<i+1<<" "<<n-1<<endl;
  15. cin>>x;
  16. if(x==n)
  17. return i;
  18.  
  19. }
  20. }
  21. return n-1;
  22. }
  23. void solve(){
  24. ll n;
  25. cin>>n;
  26. ll a[n];
  27. ll pos=getpos(n);
  28. a[pos]=n;
  29. for(ll i=0;i<n;i++){
  30. if(i==pos)
  31. continue;
  32. cout<<"? 2 "<<i+1<<" "<<pos+1<<" "<<1<<endl;
  33. cin>>a[i];
  34. }
  35. cout<<"! ";
  36. for(ll i=0;i<n;i++)
  37. cout<<a[i]<<" ";
  38. cout<<endl;
  39. }
  40.  
  41. int main(){
  42. FAST1;
  43. FAST2;
  44. ll t;
  45. cin>>t;
  46. while(t--){
  47. solve();
  48. }
  49. }
Runtime error #stdin #stdout 0s 5680KB
stdin
Standard input is empty
stdout
Standard output is empty