QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#339387#4218. Hidden Graphhos_lyricAC ✓493ms4244kbC++143.4kb2024-02-27 10:41:302024-02-27 10:41:31

Judging History

你现在查看的是最新测评结果

  • [2024-02-27 10:41:31]
  • 评测
  • 测评结果:AC
  • 用时:493ms
  • 内存:4244kb
  • [2024-02-27 10:41:30]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


int N;
vector<int> A, B;
vector<vector<int>> graph;
void ae(int u, int v) {
  A.push_back(u);
  B.push_back(v);
  graph[u].push_back(v);
  graph[v].push_back(u);
}

int main() {
  scanf("%d", &N);
  graph.assign(N, {});
  for (int n = 0; n < N; ++n) {
#define N do_not_use_N
    // (K+1)-coloring of [0, n)
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
    vector<int> deg(n);
    for (int u = 0; u < n; ++u) {
      que.emplace(deg[u] = graph[u].size(), u);
    }
    int K = 0;
    vector<int> us;
    vector<int> vis(n, 0);
    for (; que.size(); ) {
      const int c = que.top().first;
      const int u = que.top().second;
      que.pop();
      if (deg[u] == c) {
        chmax(K, deg[u]);
        us.push_back(u);
        vis[u] = 1;
        for (const int v : graph[u]) if (!vis[v]) {
          que.emplace(--deg[v], v);
        }
      }
    }
    vector<int> colors(n, -1);
    reverse(us.begin(), us.end());
    for (const int u : us) {
      vector<int> used(K + 1, 0);
      for (const int v : graph[u]) if (~colors[v]) {
        used[colors[v]] = 1;
      }
      for (int k = 0; k < K + 1; ++k) if (!used[k]) {
        colors[u] = k;
        break;
      }
      assert(~colors[u]);
    }
// cerr<<"K = "<<K<<", us = "<<us<<", colors = "<<colors<<endl;
    vector<vector<int>> uss(K + 1);
    for (int u = 0; u < n; ++u) {
      uss[colors[u]].push_back(u);
    }
    // add n: at most (K+1) failure
    for (int k = 0; k < K + 1; ++k) {
      set<int> se(uss[k].begin(), uss[k].end());
      for (; se.size(); ) {
        printf("? %d %d", 1 + (int)se.size(), n + 1);
        for (const int u : se) printf(" %d", u + 1);
        puts("");
        fflush(stdout);
        int a, b;
        scanf("%d%d", &a, &b);
        --a;
        --b;
        if (a < 0) {
          break;
        } else {
          if (a != n) swap(a, b);
          assert(a == n);
          ae(n, b);
          assert(se.erase(b));
        }
      }
    }
  }
  printf("! %d\n", (int)A.size());
  for (int i = 0; i < (int)A.size(); ++i) {
    printf("%d %d\n", A[i] + 1, B[i] + 1);
  }
  fflush(stdout);
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3784kb

input:

3
1 2
2 3
1 3

output:

? 2 2 1
? 2 3 2
? 2 3 1
! 3
2 1
3 2
3 1

result:

ok correct

Test #2:

score: 0
Accepted
time: 1ms
memory: 3848kb

input:

10
1 2
-1 -1
1 3
-1 -1
1 4
4 5
2 5
-1 -1
-1 -1
-1 -1
2 6
-1 -1
-1 -1
3 7
-1 -1
-1 -1
4 8
3 8
-1 -1
-1 -1
3 9
-1 -1
-1 -1
4 10
3 10
-1 -1

output:

? 2 2 1
? 2 3 2
? 2 3 1
? 3 4 2 3
? 2 4 1
? 4 5 2 3 4
? 3 5 2 3
? 2 5 3
? 2 5 1
? 3 6 1 5
? 4 6 2 3 4
? 3 6 3 4
? 4 7 1 5 6
? 4 7 2 3 4
? 3 7 2 4
? 5 8 1 5 6 7
? 4 8 2 3 4
? 3 8 2 3
? 2 8 2
? 6 9 1 5 6 7 8
? 4 9 2 3 4
? 3 9 2 4
? 7 10 1 5 6 7 8 9
? 4 10 2 3 4
? 3 10 2 3
? 2 10 2
! 12
2 1
3 1
4 1
5 4...

result:

ok correct

Test #3:

score: 0
Accepted
time: 1ms
memory: 3792kb

input:

5
2 1
3 2
3 1
-1 -1
4 2
4 1
-1 -1
5 2
5 1

output:

? 2 2 1
? 2 3 2
? 2 3 1
? 2 4 3
? 2 4 2
? 2 4 1
? 3 5 3 4
? 2 5 2
? 2 5 1
! 7
2 1
3 2
3 1
4 2
4 1
5 2
5 1

result:

ok correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

3
2 1
-1 -1
1 3

output:

? 2 2 1
? 2 3 2
? 2 3 1
! 2
2 1
3 1

result:

ok correct

Test #5:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

6
1 2
3 2
3 1
3 4
4 2
-1 -1
4 5
-1 -1
3 5
2 5
-1 -1
-1 -1
3 6
-1 -1

output:

? 2 2 1
? 2 3 2
? 2 3 1
? 2 4 3
? 2 4 2
? 2 4 1
? 3 5 1 4
? 2 5 1
? 2 5 3
? 2 5 2
? 3 6 1 5
? 2 6 4
? 2 6 3
? 2 6 2
! 9
2 1
3 2
3 1
4 3
4 2
5 4
5 3
5 2
6 3

result:

ok correct

Test #6:

score: 0
Accepted
time: 2ms
memory: 3796kb

input:

27
-1 -1
3 1
3 2
-1 -1
-1 -1
3 5
-1 -1
1 5
2 5
-1 -1
-1 -1
6 1
-1 -1
-1 -1
-1 -1
-1 -1
6 8
-1 -1
-1 -1
1 8
-1 -1
-1 -1
-1 -1
1 9
-1 -1
10 8
-1 -1
-1 -1
-1 -1
4 11
5 11
-1 -1
6 11
-1 -1
1 11
-1 -1
12 11
-1 -1
5 12
-1 -1
-1 -1
10 13
-1 -1
8 13
-1 -1
6 13
5 13
14 1
14 12
-1 -1
14 8
-1 -1
14 5
6 14
-1 -...

output:

? 2 2 1
? 3 3 1 2
? 2 3 2
? 2 4 3
? 3 4 1 2
? 3 5 3 4
? 2 5 4
? 3 5 1 2
? 2 5 2
? 3 6 4 5
? 2 6 3
? 3 6 1 2
? 2 6 2
? 4 7 4 5 6
? 2 7 3
? 3 7 1 2
? 5 8 4 5 6 7
? 4 8 4 5 7
? 2 8 3
? 3 8 1 2
? 2 8 2
? 5 9 4 5 7 8
? 3 9 3 6
? 3 9 1 2
? 2 9 2
? 6 10 4 5 7 8 9
? 5 10 4 5 7 9
? 3 10 3 6
? 3 10 1 2
? 6 11...

result:

ok correct

Test #7:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

47
-1 -1
-1 -1
-1 -1
5 4
5 3
-1 -1
-1 -1
-1 -1
7 5
7 6
-1 -1
-1 -1
-1 -1
5 8
-1 -1
9 4
-1 -1
-1 -1
-1 -1
10 7
-1 -1
11 1
-1 -1
7 11
-1 -1
11 12
2 12
5 12
-1 -1
7 12
12 3
-1 -1
-1 -1
13 11
13 5
-1 -1
13 7
-1 -1
-1 -1
-1 -1
-1 -1
4 15
13 15
-1 -1
-1 -1
-1 -1
16 1
-1 -1
-1 -1
-1 -1
17 8
17 1
-1 -1
17 1...

output:

? 2 2 1
? 3 3 1 2
? 4 4 1 2 3
? 5 5 1 2 3 4
? 4 5 1 2 3
? 3 5 1 2
? 4 6 1 2 5
? 3 6 3 4
? 5 7 1 2 5 6
? 4 7 1 2 6
? 3 7 1 2
? 3 7 3 4
? 6 8 1 2 3 4 7
? 3 8 5 6
? 2 8 6
? 7 9 1 2 3 4 7 8
? 6 9 1 2 3 7 8
? 3 9 5 6
? 6 10 1 2 5 6 9
? 5 10 3 4 7 8
? 4 10 3 4 8
? 7 11 1 2 5 6 9 10
? 6 11 2 5 6 9 10
? 5 1...

result:

ok correct

Test #8:

score: 0
Accepted
time: 2ms
memory: 3796kb

input:

38
-1 -1
-1 -1
4 1
-1 -1
3 5
4 5
-1 -1
1 5
-1 -1
4 6
-1 -1
-1 -1
6 7
7 5
2 7
4 7
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
4 10
11 1
-1 -1
-1 -1
11 4
12 8
11 12
-1 -1
-1 -1
12 7
-1 -1
13 8
11 13
-1 -1
13 12
4 13
-1 -1
13 1
-1 -1
3 14
-1 -1
11 14
14 5
6 14
-1 -1
-1 -1
1 14
-1 -1
-1 ...

output:

? 2 2 1
? 3 3 1 2
? 4 4 1 2 3
? 3 4 2 3
? 4 5 2 3 4
? 3 5 2 4
? 2 5 2
? 2 5 1
? 3 6 2 5
? 3 6 3 4
? 2 6 3
? 2 6 1
? 4 7 2 5 6
? 3 7 2 5
? 2 7 2
? 3 7 3 4
? 2 7 3
? 2 7 1
? 4 8 1 3 7
? 4 8 2 5 6
? 2 8 4
? 5 9 1 3 7 8
? 4 9 2 5 6
? 2 9 4
? 6 10 1 3 7 8 9
? 4 10 2 5 6
? 2 10 4
? 7 11 1 3 7 8 9 10
? 6 1...

result:

ok correct

Test #9:

score: 0
Accepted
time: 1ms
memory: 3856kb

input:

25
-1 -1
-1 -1
-1 -1
5 4
5 2
-1 -1
-1 -1
6 4
-1 -1
5 7
7 3
-1 -1
-1 -1
4 8
2 8
-1 -1
5 8
-1 -1
9 8
-1 -1
-1 -1
2 9
9 4
10 3
-1 -1
-1 -1
-1 -1
9 11
-1 -1
10 11
-1 -1
2 11
-1 -1
6 12
-1 -1
-1 -1
12 4
-1 -1
5 13
-1 -1
7 13
13 8
6 13
-1 -1
-1 -1
5 14
-1 -1
7 14
-1 -1
14 13
14 3
14 4
-1 -1
-1 -1
-1 -1
10...

output:

? 2 2 1
? 3 3 1 2
? 4 4 1 2 3
? 5 5 1 2 3 4
? 4 5 1 2 3
? 3 5 1 3
? 4 6 1 3 5
? 3 6 2 4
? 2 6 2
? 5 7 1 3 5 6
? 4 7 1 3 6
? 3 7 1 6
? 3 7 2 4
? 5 8 1 2 4 7
? 4 8 1 2 7
? 3 8 1 7
? 4 8 3 5 6
? 3 8 3 6
? 5 9 1 6 7 8
? 4 9 1 6 7
? 3 9 3 5
? 3 9 2 4
? 2 9 4
? 6 10 1 3 5 6 9
? 5 10 1 5 6 9
? 3 10 7 8
? 3...

result:

ok correct

Test #10:

score: 0
Accepted
time: 1ms
memory: 3832kb

input:

6
-1 -1
2 3
-1 -1
-1 -1
-1 -1
-1 -1
2 5
5 6
-1 -1
-1 -1

output:

? 2 2 1
? 3 3 1 2
? 2 3 1
? 3 4 1 3
? 2 4 2
? 4 5 1 3 4
? 2 5 2
? 5 6 1 3 4 5
? 4 6 1 3 4
? 2 6 2
! 3
3 2
5 2
6 5

result:

ok correct

Test #11:

score: 0
Accepted
time: 1ms
memory: 3792kb

input:

3
2 1
2 3
3 1

output:

? 2 2 1
? 2 3 2
? 2 3 1
! 3
2 1
3 2
3 1

result:

ok correct

Test #12:

score: 0
Accepted
time: 0ms
memory: 4068kb

input:

3
2 1
-1 -1
3 1

output:

? 2 2 1
? 2 3 2
? 2 3 1
! 2
2 1
3 1

result:

ok correct

Test #13:

score: 0
Accepted
time: 0ms
memory: 4080kb

input:

5
2 1
2 3
3 1
-1 -1
-1 -1
-1 -1
-1 -1
2 5
5 1

output:

? 2 2 1
? 2 3 2
? 2 3 1
? 2 4 3
? 2 4 2
? 2 4 1
? 3 5 3 4
? 2 5 2
? 2 5 1
! 5
2 1
3 2
3 1
5 2
5 1

result:

ok correct

Test #14:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

3
2 1
-1 -1
-1 -1

output:

? 2 2 1
? 2 3 2
? 2 3 1
! 1
2 1

result:

ok correct

Test #15:

score: 0
Accepted
time: 1ms
memory: 4060kb

input:

5
-1 -1
-1 -1
4 3
-1 -1
2 5
-1 -1
3 5

output:

? 2 2 1
? 3 3 1 2
? 4 4 1 2 3
? 3 4 1 2
? 4 5 1 2 4
? 3 5 1 4
? 2 5 3
! 3
4 3
5 2
5 3

result:

ok correct

Test #16:

score: 0
Accepted
time: 3ms
memory: 3824kb

input:

93
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
10 9
-1 -1
7 11
-1 -1
-1 -1
2 12
-1 -1
-1 -1
5 13
-1 -1
-1 -1
-1 -1
-1 -1
15 12
-1 -1
-1 -1
6 16
8 16
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
19 18
11 19
-1 -1
-1 -1
20 16
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
1 23
8 23
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
1 25
...

output:

? 2 2 1
? 3 3 1 2
? 4 4 1 2 3
? 5 5 1 2 3 4
? 6 6 1 2 3 4 5
? 7 7 1 2 3 4 5 6
? 8 8 1 2 3 4 5 6 7
? 9 9 1 2 3 4 5 6 7 8
? 10 10 1 2 3 4 5 6 7 8 9
? 9 10 1 2 3 4 5 6 7 8
? 10 11 1 2 3 4 5 6 7 8 10
? 9 11 1 2 3 4 5 6 8 10
? 2 11 9
? 10 12 1 2 3 4 5 6 8 10 11
? 9 12 1 3 4 5 6 8 10 11
? 3 12 7 9
? 10 13...

result:

ok correct

Test #17:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

111
-1 -1
-1 -1
-1 -1
-1 -1
2 6
-1 -1
7 4
-1 -1
-1 -1
3 8
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
2 11
4 11
-1 -1
6 12
7 12
12 11
-1 -1
12 4
-1 -1
13 10
-1 -1
7 13
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
17 10
-1 -1
-1 -1
18 5
-1 -1
-1 -1
4 18
16 19
-1 -1
11 19
-1 -...

output:

? 2 2 1
? 3 3 1 2
? 4 4 1 2 3
? 5 5 1 2 3 4
? 6 6 1 2 3 4 5
? 5 6 1 3 4 5
? 6 7 1 3 4 5 6
? 5 7 1 3 5 6
? 2 7 2
? 6 8 1 3 5 6 7
? 5 8 1 5 6 7
? 3 8 2 4
? 6 9 1 5 6 7 8
? 4 9 2 3 4
? 7 10 1 5 6 7 8 9
? 4 10 2 3 4
? 8 11 1 5 6 7 8 9 10
? 4 11 2 3 4
? 3 11 3 4
? 2 11 3
? 9 12 1 5 6 7 8 9 10 11
? 8 12 1...

result:

ok correct

Test #18:

score: 0
Accepted
time: 0ms
memory: 4100kb

input:

132
-1 -1
3 1
-1 -1
-1 -1
-1 -1
-1 -1
5 1
6 3
-1 -1
-1 -1
7 2
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
10 8
-1 -1
5 10
-1 -1
-1 -1
-1 -1
-1 -1
12 8
-1 -1
9 13
-1 -1
-1 -1
-1 -1
2 14
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
17 15
-1 -1
-1 -1
-1 -1
-1 -1
19 10
17 19
19 6
-1 -1
-1 -1
-1 -1
-1 -1
21 20
-1 -1
-1 -1
22 8...

output:

? 2 2 1
? 3 3 1 2
? 2 3 2
? 3 4 2 3
? 2 4 1
? 4 5 2 3 4
? 2 5 1
? 5 6 2 3 4 5
? 4 6 2 4 5
? 2 6 1
? 5 7 1 2 4 6
? 4 7 1 4 6
? 3 7 3 5
? 5 8 1 4 6 7
? 4 8 2 3 5
? 6 9 1 4 6 7 8
? 4 9 2 3 5
? 7 10 1 4 6 7 8 9
? 6 10 1 4 6 7 9
? 4 10 2 3 5
? 3 10 2 3
? 7 11 1 4 6 7 9 10
? 5 11 2 3 5 8
? 8 12 1 4 6 7 9 ...

result:

ok correct

Test #19:

score: 0
Accepted
time: 4ms
memory: 3816kb

input:

94
-1 -1
3 2
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
2 7
-1 -1
-1 -1
7 9
-1 -1
2 9
-1 -1
-1 -1
-1 -1
11 6
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
11 13
-1 -1
6 13
-1 -1
-1 -1
14 10
-1 -1
14 11
-1 -1
-1 -1
-1 -1
15 11
-1 -1
-1 -1
15 16
-1 -1
16 7
-1 -1
-1 -1
17 8
-1 -1
17 10
17 11
-1 -1
-1 -1
-1 ...

output:

? 2 2 1
? 3 3 1 2
? 2 3 1
? 3 4 1 3
? 2 4 2
? 4 5 1 3 4
? 2 5 2
? 5 6 1 3 4 5
? 2 6 2
? 6 7 1 3 4 5 6
? 2 7 2
? 7 8 1 3 4 5 6 7
? 2 8 2
? 8 9 1 3 4 5 6 7 8
? 7 9 1 3 4 5 6 8
? 2 9 2
? 8 10 1 3 4 5 6 8 9
? 2 10 7
? 2 10 2
? 9 11 1 3 4 5 6 8 9 10
? 8 11 1 3 4 5 8 9 10
? 2 11 7
? 2 11 2
? 9 12 1 3 4 5 ...

result:

ok correct

Test #20:

score: 0
Accepted
time: 5ms
memory: 4060kb

input:

73
-1 -1
1 3
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
5 7
6 7
-1 -1
-1 -1
3 8
-1 -1
-1 -1
1 9
9 8
-1 -1
-1 -1
3 10
9 10
4 10
-1 -1
1 10
-1 -1
-1 -1
4 11
-1 -1
-1 -1
12 10
-1 -1
12 9
12 3
-1 -1
-1 -1
-1 -1
13 11
13 6
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
15 8
-1 -1
-1 -1
-1 -1
16 14
1 16
-1 -1
10 16
-1 -1
3...

output:

? 2 2 1
? 3 3 1 2
? 2 3 2
? 3 4 2 3
? 2 4 1
? 4 5 2 3 4
? 2 5 1
? 5 6 2 3 4 5
? 2 6 1
? 6 7 2 3 4 5 6
? 5 7 2 3 4 6
? 4 7 2 3 4
? 2 7 1
? 5 8 2 3 4 7
? 4 8 2 4 7
? 4 8 1 5 6
? 6 9 1 2 4 7 8
? 5 9 2 4 7 8
? 4 9 2 4 7
? 4 9 3 5 6
? 6 10 2 3 4 7 9
? 5 10 2 4 7 9
? 4 10 2 4 7
? 3 10 2 7
? 5 10 1 5 6 8
?...

result:

ok correct

Test #21:

score: 0
Accepted
time: 1ms
memory: 3776kb

input:

77
-1 -1
3 2
-1 -1
-1 -1
2 4
-1 -1
-1 -1
3 6
-1 -1
-1 -1
-1 -1
3 7
-1 -1
-1 -1
3 8
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
1 11
-1 -1
-1 -1
-1 -1
-1 -1
8 13
-1 -1
-1 -1
-1 -1
2 14
14 8
14 7
-1 -1
3 15
-1 -1
15 8
2 15
-1 -1
16 15
-1 -1
16 8
16 1
2 16
-1 -1
-1 -1
-1 -1
7 17
-1 -1
2 17
-1 -1
-1 -1
-1 -1
-1 -1
-1...

output:

? 2 2 1
? 3 3 1 2
? 2 3 1
? 3 4 1 3
? 2 4 2
? 4 5 1 3 4
? 2 5 2
? 5 6 1 3 4 5
? 4 6 1 4 5
? 2 6 2
? 5 7 1 2 5 6
? 3 7 3 4
? 2 7 4
? 6 8 1 2 5 6 7
? 3 8 3 4
? 2 8 4
? 7 9 1 2 5 6 7 8
? 3 9 3 4
? 8 10 1 2 5 6 7 8 9
? 3 10 3 4
? 9 11 1 2 5 6 7 8 9 10
? 8 11 2 5 6 7 8 9 10
? 3 11 3 4
? 9 12 2 5 6 7 8 9 ...

result:

ok correct

Test #22:

score: 0
Accepted
time: 6ms
memory: 3816kb

input:

81
-1 -1
2 3
-1 -1
-1 -1
2 4
4 5
1 5
-1 -1
-1 -1
-1 -1
4 6
-1 -1
-1 -1
-1 -1
-1 -1
1 8
-1 -1
-1 -1
-1 -1
2 10
10 6
-1 -1
10 4
10 3
-1 -1
-1 -1
-1 -1
11 3
4 11
8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 2 10 1
? 7 11 3 4 5 7 9 10
? 4...

result:

ok correct

Test #24:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

37
-1 -1
3 1
-1 -1
-1 -1
-1 -1
2 5
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
7 1
2 7
6 8
7 8
4 8
-1 -1
2 8
1 8
9 8
-1 -1
6 9
-1 -1
9 1
2 9
3 10
-1 -1
10 8
1 10
-1 -1
9 11
4 11
7 11
-1 -1
3 11
11 8
11 1
2 11
-1 -1
-1 -1
12 7
-1 -1
12 8
12 1
-1 -1
12 13
6 13
-1 -1
-1 -1
-1 -1
-1 -1
6 14
14 5
-1 -1
14 3
-1 -1
14 8...

output:

? 2 2 1
? 3 3 1 2
? 2 3 2
? 3 4 2 3
? 2 4 1
? 4 5 2 3 4
? 3 5 3 4
? 2 5 1
? 4 6 3 4 5
? 3 6 1 2
? 5 7 3 4 5 6
? 3 7 1 2
? 2 7 2
? 6 8 3 4 5 6 7
? 5 8 3 4 5 7
? 4 8 3 4 5
? 3 8 3 5
? 3 8 1 2
? 2 8 1
? 4 9 3 5 8
? 3 9 3 5
? 4 9 4 6 7
? 3 9 4 7
? 3 9 1 2
? 2 9 2
? 6 10 3 4 5 7 9
? 5 10 4 5 7 9
? 2 10 8...

result:

ok correct

Test #25:

score: 0
Accepted
time: 5ms
memory: 4112kb

input:

144
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
9 15
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
14 18
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
5 22
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -...

output:

? 2 2 1
? 3 3 1 2
? 4 4 1 2 3
? 5 5 1 2 3 4
? 6 6 1 2 3 4 5
? 7 7 1 2 3 4 5 6
? 8 8 1 2 3 4 5 6 7
? 9 9 1 2 3 4 5 6 7 8
? 10 10 1 2 3 4 5 6 7 8 9
? 11 11 1 2 3 4 5 6 7 8 9 10
? 12 12 1 2 3 4 5 6 7 8 9 10 11
? 13 13 1 2 3 4 5 6 7 8 9 10 11 12
? 14 14 1 2 3 4 5 6 7 8 9 10 11 12 13
? 15 15 1 2 3 4 5 6 ...

result:

ok correct

Test #26:

score: 0
Accepted
time: 61ms
memory: 4244kb

input:

561
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
26 22
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1...

output:

? 2 2 1
? 3 3 1 2
? 4 4 1 2 3
? 5 5 1 2 3 4
? 6 6 1 2 3 4 5
? 7 7 1 2 3 4 5 6
? 8 8 1 2 3 4 5 6 7
? 9 9 1 2 3 4 5 6 7 8
? 10 10 1 2 3 4 5 6 7 8 9
? 11 11 1 2 3 4 5 6 7 8 9 10
? 12 12 1 2 3 4 5 6 7 8 9 10 11
? 13 13 1 2 3 4 5 6 7 8 9 10 11 12
? 14 14 1 2 3 4 5 6 7 8 9 10 11 12 13
? 15 15 1 2 3 4 5 6 ...

result:

ok correct

Test #27:

score: 0
Accepted
time: 84ms
memory: 4032kb

input:

679
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 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 13 13 1 2 3 4 5 6 7 8 9 10 11 12
? 14 14 1 2 3 4 5 6 7 8 9 10 11 12 13
? 15 15 1 2 3 4 5 6 ...

result:

ok correct

Test #29:

score: 0
Accepted
time: 137ms
memory: 4028kb

input:

1000
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
13 14
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
6 22
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1...

output:

? 2 2 1
? 3 3 1 2
? 4 4 1 2 3
? 5 5 1 2 3 4
? 6 6 1 2 3 4 5
? 7 7 1 2 3 4 5 6
? 8 8 1 2 3 4 5 6 7
? 9 9 1 2 3 4 5 6 7 8
? 10 10 1 2 3 4 5 6 7 8 9
? 11 11 1 2 3 4 5 6 7 8 9 10
? 12 12 1 2 3 4 5 6 7 8 9 10 11
? 13 13 1 2 3 4 5 6 7 8 9 10 11 12
? 14 14 1 2 3 4 5 6 7 8 9 10 11 12 13
? 13 14 1 2 3 4 5 6 ...

result:

ok correct

Test #30:

score: 0
Accepted
time: 493ms
memory: 4152kb

input:

2000
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
44 15
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-...

output:

? 2 2 1
? 3 3 1 2
? 4 4 1 2 3
? 5 5 1 2 3 4
? 6 6 1 2 3 4 5
? 7 7 1 2 3 4 5 6
? 8 8 1 2 3 4 5 6 7
? 9 9 1 2 3 4 5 6 7 8
? 10 10 1 2 3 4 5 6 7 8 9
? 11 11 1 2 3 4 5 6 7 8 9 10
? 12 12 1 2 3 4 5 6 7 8 9 10 11
? 13 13 1 2 3 4 5 6 7 8 9 10 11 12
? 14 14 1 2 3 4 5 6 7 8 9 10 11 12 13
? 15 15 1 2 3 4 5 6 ...

result:

ok correct