QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#152326#4218. Hidden GraphHaccerKatAC ✓389ms3796kbC++206.5kb2023-08-28 01:43:062023-08-28 01:43:07

Judging History

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

  • [2023-08-28 01:43:07]
  • 评测
  • 测评结果:AC
  • 用时:389ms
  • 内存:3796kb
  • [2023-08-28 01:43:06]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
template<typename T>
int SIZE(T (&t)){
    return t.size();
}

template<typename T, size_t N>
int SIZE(T (&t)[N]){
    return N;
}

string to_string(char t){
    return "'" + string({t}) + "'";
}

string to_string(bool t){
    return t ? "true" : "false";
}

string to_string(const string &t, int x1=0, int x2=1e9){
    string ret = "";
    for(int i = min(x1,SIZE(t)), _i = min(x2,SIZE(t)-1); i <= _i; ++i){
        ret += t[i];
    }
    return '"' + ret + '"';
}

string to_string(const char* t){
    string ret(t);
    return to_string(ret);
}

template<size_t N>
string to_string(const bitset<N> &t, int x1=0, int x2=1e9){
    string ret = "";
    for(int i = min(x1,SIZE(t)); i <= min(x2,SIZE(t)-1); ++i){
        ret += t[i] + '0';
    }
    return to_string(ret);
}

template<typename T, typename... Coords>
string to_string(const T (&t), int x1=0, int x2=1e9, Coords... C);

template<typename T, typename S>
string to_string(const pair<T, S> &t){
    return "(" + to_string(t.first) + ", " + to_string(t.second) + ")";
}

template<typename T, typename... Coords>
string to_string(const T (&t), int x1, int x2, Coords... C){
    string ret = "[";
    x1 = min(x1, SIZE(t));
    auto e = begin(t);
    advance(e,x1);
    for(int i = x1, _i = min(x2,SIZE(t)-1); i <= _i; ++i){
        ret += to_string(*e, C...) + (i != _i ? ", " : "");
        e = next(e);
    }
    return ret + "]";
}

template<int Index, typename... Ts>
struct print_tuple{
    string operator() (const tuple<Ts...>& t) {
        string ret = print_tuple<Index - 1, Ts...>{}(t);
        ret += (Index ? ", " : "");
        return ret + to_string(get<Index>(t));
    }
};

template<typename... Ts>
struct print_tuple<0, Ts...> {
    string operator() (const tuple<Ts...>& t) {
        return to_string(get<0>(t));
    }
};

template<typename... Ts>
string to_string(const tuple<Ts...>& t) {
    const auto Size = tuple_size<tuple<Ts...>>::value;
    return print_tuple<Size - 1, Ts...>{}(t);
}

void dbgr(){;}
template<typename Heads, typename... Tails>
void dbgr(Heads H, Tails... T){
    cout << to_string(H) << " | ";
    dbgr(T...);
}

void dbgs(){;}
template<typename Heads, typename... Tails>
void dbgs(Heads H, Tails... T){
    cout << H << " ";
    dbgs(T...);
}

/*
formatted functions:
*/

/*
consider __VA_ARGS__ as a whole:
dbgv() prints values only
dbg() prints name and values
*/
#define dbgv(...) cout << to_string(__VA_ARGS__) << endl;

#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgv(__VA_ARGS__);
//#define dbg(...)

/*
consider __VA_ARGS__ as a sequence of arguments:
dbgr() prints values only
dbgm() prints names and values
*/
#define dbgr(...) dbgr(__VA_ARGS__); cout << endl;

#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgr(__VA_ARGS__);

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
// using u128 = __uint128_t;
// using i128 = __int128;
const int mod = 1000000007;
const int N = 2005;
const int LOG = 20;
const int inf = 1e9;
const double eps = 1e-11;
int n, m, qq;
vector<int> sets[N], adj[N];
int colour[N], deg[N], curdeg[N];
bitset<N> vis, colourvis;
pi query(vector<int> a) {
    cout << "? " << a.size() << " ";
    for (int x : a) cout << x << " ";
    cout << endl;
    int i, j;
    cin >> i >> j;
    return {i, j};   
}

void solve() {
    cin >> n;
    vector<pi> edges;
    for (int i = 2; i <= n; i++) {
        int addto = -1;
        priority_queue<pi, vector<pi>, greater<pi>> q;
        for (int j = 1; j < i; j++) {
            curdeg[j] = deg[j], colour[j] = -1, vis[j] = 0;
            q.push({deg[j], j});
        }
        
        vector<int> order;
        while (!q.empty()) {
            auto [d, u] = q.top();
            q.pop();
            if (d != curdeg[u]) continue;
            vis[u] = 1;
            order.push_back(u);
            for (int v : adj[u]) {
                curdeg[v]--;
                if (!vis[v]) q.push({curdeg[v], v});
            }
        }
        
        reverse(order.begin(), order.end());
        int mxx = 0;
        for (int u : order) {
            int mx = 0;
            for (int v : adj[u]) {
                int c = colour[v];
                if (c == -1) continue;
                colourvis[c] = 1, mx = max(mx, c);
            }
            
            int c = inf;
            for (int j = 0; j <= mx + 1; j++) {
                if (!colourvis[j]) {
                    c = min(c, j);
                }
                
                colourvis[j] = 0;
            }
            
            // dbgm(u, c, deg[u], curdeg[u]);
            mxx = max(mxx, c), colour[u] = c;
            sets[c].push_back(u);
        }
        
        for (int j = 0; j <= mxx; j++) {
            vector<int> s = sets[j];
            while (true) {
                vector<int> q = s;
                q.push_back(i);
                auto [u, v] = query(q);
                if (u == -1) {
                    break;
                }
                
                else {
                    edges.push_back({u, v});
                    adj[u].push_back(v);
                    adj[v].push_back(u);
                    deg[u]++, deg[v]++;
                    vector<int> ns;
                    for (int k = 0; k < s.size(); k++) {
                        if (s[k] != u && s[k] != v) {
                            ns.push_back(s[k]);
                        }
                    }
                    
                    s = ns;
                }
            }
        }
        
        for (int j = 0; j <= mxx; j++) {
            sets[j].clear();
        }
    }
    
    cout << "! " << edges.size() << "\n";
    for (auto [u, v] : edges) {
        cout << u << " " << v << "\n";
    }
}

int32_t main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok correct

Test #2:

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

input:

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

result:

ok correct

Test #3:

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

input:

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

output:

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

result:

ok correct

Test #4:

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

input:

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

output:

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

result:

ok correct

Test #5:

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

input:

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

output:

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

result:

ok correct

Test #6:

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

input:

27
-1 -1
3 1
3 2
-1 -1
-1 -1
-1 -1
3 5
-1 -1
2 5
1 5
-1 -1
-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
5 11
4 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
-1 -1
14 1
14 12
-1 -1
14 8
-1...

output:

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

result:

ok correct

Test #7:

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

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

result:

ok correct

Test #8:

score: 0
Accepted
time: 8ms
memory: 3632kb

input:

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

output:

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

result:

ok correct

Test #9:

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

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
-1 -1
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
13 8
7 13
6 13
-1 -1
-1 -1
5 14
-1 -1
7 14
-1 -1
14 3
14 13
14 4
-1 -1
-1 -1
-1...

output:

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

result:

ok correct

Test #10:

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

input:

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

output:

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

result:

ok correct

Test #11:

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

input:

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

output:

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

result:

ok correct

Test #12:

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

input:

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

output:

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

result:

ok correct

Test #13:

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

input:

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

output:

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

result:

ok correct

Test #14:

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

input:

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

output:

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

result:

ok correct

Test #15:

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

input:

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

output:

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

result:

ok correct

Test #16:

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

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

result:

ok correct

Test #17:

score: 0
Accepted
time: 8ms
memory: 3580kb

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
-1 -1
16 19
-1 -1
11 1...

output:

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

result:

ok correct

Test #18:

score: 0
Accepted
time: 8ms
memory: 3596kb

input:

132
-1 -1
3 1
-1 -1
-1 -1
-1 -1
-1 -1
5 1
-1 -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
17 19
19 10
19 6
-1 -1
-1 -1
-1 -1
-1 -1
21 20
-1 -1
-1 -...

output:

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

result:

ok correct

Test #19:

score: 0
Accepted
time: 13ms
memory: 3632kb

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
-1 -1
7 9
-1 -1
2 9
-1 -1
-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 11
17 10
-1 ...

output:

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

result:

ok correct

Test #20:

score: 0
Accepted
time: 17ms
memory: 3608kb

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

result:

ok correct

Test #21:

score: 0
Accepted
time: 10ms
memory: 3676kb

input:

77
-1 -1
3 2
-1 -1
-1 -1
2 4
-1 -1
-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...

output:

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

result:

ok correct

Test #22:

score: 0
Accepted
time: 8ms
memory: 3692kb

input:

81
-1 -1
2 3
-1 -1
-1 -1
2 4
-1 -1
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
10 6
2 10
-1 -1
10 3
10 4
-1 -1
-1 -1
-1 -1
4 11
11 3
-1 -1
8 12
-1 -1
-1 -1
6 12
2 12
-1 -1
10 13
-1 -1
-1 -1
-1 -1
10 14
-1 -1
-1 -1
1 14
-1 -1
-1 -1
13 15
-1 -1
-1 -1
1 16
12 16
11 16
-1...

output:

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

result:

ok correct

Test #23:

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

input:

93
-1 -1
-1 -1
4 1
2 4
-1 -1
-1 -1
-1 -1
4 6
-1 -1
-1 -1
2 7
-1 -1
-1 -1
3 8
-1 -1
1 8
-1 -1
9 8
-1 -1
9 1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
13 7
-1 -1
-1 -1
-1 -1
9 14
4 14
-1 -1
-1 -1
1 14
-1 -1
14 15
-1 -1
-1 -1
-1 -1
13 16
-1 -1
-1 -1
-1 -1
17 8
2 17
17 5
-1 -1
17 3
17 ...

output:

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

result:

ok correct

Test #24:

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

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

result:

ok correct

Test #26:

score: 0
Accepted
time: 39ms
memory: 3636kb

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

result:

ok correct

Test #27:

score: 0
Accepted
time: 63ms
memory: 3592kb

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 -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
39 40
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1...

output:

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

result:

ok correct

Test #28:

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

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

result:

ok correct

Test #29:

score: 0
Accepted
time: 132ms
memory: 3684kb

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

result:

ok correct