fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define int long long
  4.  
  5. #define debug cout << "ok\n";
  6. #define SQR(x) (1LL * ((x) * (x)))
  7. #define MASK(i) (1LL << (i))
  8. #define BIT(x, i) (((x) >> (i)) & 1)
  9. #define fi first
  10. #define se second
  11. #define pb push_back
  12.  
  13. #define mp make_pair
  14. #define pii pair<int,int>
  15. #define pli pair<ll,int>
  16. #define vi vector<int>
  17.  
  18. #define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  19.  
  20. typedef long long ll;
  21. typedef unsigned long long ull;
  22. typedef long double ld;
  23. typedef unsigned int ui;
  24.  
  25. using namespace std;
  26.  
  27. const int M = 1e9 + 7;
  28. const int INF = 1e9 + 7;
  29. const ll INFLL = (ll)2e18 + 7LL;
  30. const ld PI = acos(-1);
  31.  
  32. const int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
  33. const int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
  34.  
  35. template<class _, class __>
  36. bool minimize(_ &x, const __ y){
  37. if(x > y){
  38. x = y;
  39. return true;
  40. } else return false;
  41. }
  42. template<class _, class __>
  43. bool maximize(_ &x, const __ y){
  44. if(x < y){
  45. x = y;
  46. return true;
  47. } else return false;
  48. }
  49.  
  50. template<class _,class __>
  51. void Add(_ &x, const __ y) {
  52. x += y;
  53. if (x >= M) {
  54. x -= M;
  55. }
  56. return;
  57. }
  58.  
  59. template<class _,class __>
  60. void Diff(_ &x, const __ y) {
  61. x -= y;
  62. if (x < 0) {
  63. x += M;
  64. }
  65. return;
  66. }
  67.  
  68. //--------------------------------------------------------------
  69.  
  70. const int MaxN = 1e6+7;
  71.  
  72. int n,dist[MaxN];
  73. pii a[MaxN];
  74.  
  75. void sol() {
  76. cin >> n;
  77. for (int i=1;i<=n;i++) {
  78. cout << '?' << ' ' << i << ' ' << n << ' ';
  79. for (int j=1;j<=n;j++) cout << j << ' ';
  80. cout << endl;
  81. cin >> dist[i];
  82. }
  83. // for (int i=1;i<=n;i++) cout << dist[i] << ' ';
  84. for (int i=1;i<=n;i++) {
  85. a[i] = mp(dist[i],i);
  86. }
  87. // debug;
  88. sort(a+1,a+n+1,greater<pii>());
  89. vi res;
  90. res.pb(a[1].se);
  91. // debug;
  92. for (int i=1;i<=n;) {
  93. while (i <= n && a[i].fi == dist[res.back()]) i++;
  94. int j = i;
  95. // cout << i << ' ';
  96. for (;j<=n && a[j].fi == a[i].fi;j++) {
  97. cout << '?' << ' ' << res.back() << ' ' << 1 << ' ' << a[j].se << endl;
  98. int tmp;
  99. cin >> tmp;
  100. if (tmp == 2) {
  101. res.pb(a[j].se);
  102. break;
  103. }
  104. }
  105. }
  106. cout << '!' << ' ' << res.size() << ' ';
  107. for (int x : res) cout << x << ' ';
  108. cout << endl;
  109. }
  110.  
  111. signed main() {
  112. // freopen("test.inp","r",stdin);
  113. // freopen("test.out","w",stdout);
  114. // FAST
  115. int t=1;
  116. cin >> t;
  117. while (t--) sol();
  118. }
  119.  
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
! 1 0