-
Notifications
You must be signed in to change notification settings - Fork 0
/
D.cpp
46 lines (45 loc) · 857 Bytes
/
D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "bits/stdc++.h"
using namespace std;
typedef pair <int, int> pii;
pair <int, int> ask(vector <int> v) {
cout << "?";
for(auto i : v) {
cout << " " << i;
}
cout << endl;
int pos, val;
cin >> pos >> val;
return make_pair(pos, val);
}
int main(int argc, char const *argv[])
{
int n, k;
cin >> n >> k;
vector <int> v;
for(int i = 1; i <= k; i++) {
v.push_back(i);
}
pii p = ask(v);
v.erase(find(v.begin(), v.end(), p.first));
v.push_back(k + 1);
pii q = ask(v);
v.pop_back();
v.push_back(p.first);
int cnt = 0;
for(auto i : v) {
if(i == p.first) continue;
vector <int> u;
for(auto j : v) {
if(i != j) u.push_back(j);
}
u.push_back(k + 1);
pii r = ask(u);
if(r.first == p.first) ++cnt;
}
if(q.second < p.second) {
cout << "! " << cnt + 1 << endl;
} else {
cout << "! " << k - cnt << endl;
}
return 0;
}