QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#190405#3675. Interactive Array GuessingIsaacMoris#ML 1ms3568kbC++171.3kb2023-09-28 20:35:522024-01-17 03:30:16

Judging History

This is the latest submission verdict.

  • [2024-01-17 03:30:16]
  • 管理员手动重测该提交记录
  • Verdict: ML
  • Time: 1ms
  • Memory: 3568kb
  • [2023-09-28 20:35:52]
  • Submitted

answer

#include<iostream>
#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 2e5 + 5;


vector<vector<int> > ans;

void solve(int l, int r) {
    if (l > r)return;
    cout << "? " << 2 * (r - l + 1);
    for (int i = l; i <= r; i++) {
        cout << " " << i << " " << i;
    }
    cout << "\n";
    cout.flush();

    int sz;
    cin >> sz;
    set<int> vis;
    bool flag = false;
    while (sz--) {
        int x;
        cin >> x;
        if (vis.count(x) == 0) {
            vis.insert(x);
            flag = false;
        } else {
            if (!flag) {
                ans.push_back({});
                flag = true;
            }
            vis.erase(x);
            ans.back().push_back(x);
        }
    }
}

void doWork() {
    int n;
    cin >> n;
    solve(1, n / 2);
    solve(n / 2 + 1, n - 1);
    solve(n, n);

    cout << "! ";
    for (auto i: ans) {
        cout << i.size() << " ";
        for (auto j: i) {
            cout << j << " ";
        }
    }
    cout.flush();
}

int main() {
    IO
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        //  cout << "Case #" << i << ": ";
        doWork();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

input:

3
2 1 1
4 1 2 1 2
4 2 1 2 1

output:

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

result:

ok 3 arrays, sum_len = 5

Test #2:

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

input:

3
4 2 3 2 3
2 2 2
6 1 4 2 1 4 2

output:

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

result:

ok 3 arrays, sum_len = 6

Test #3:

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

input:

3
4 1 2 1 2
4 1 2 1 2
4 2 1 2 1

output:

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

result:

ok 3 arrays, sum_len = 6

Test #4:

score: -100
Memory Limit Exceeded

input:

1

output:

? 2 1 1

result: