-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCF_1407C.cpp
More file actions
48 lines (45 loc) · 833 Bytes
/
CF_1407C.cpp
File metadata and controls
48 lines (45 loc) · 833 Bytes
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
47
48
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <functional>
#include <cstdlib>
#include <list>
#include <iomanip>
#define ll long long
using namespace std;
int main() {
int N;
cin >> N;
int maxim = 0;
int maxim_idx = 1;
vector<int> v(N+1, 0);
for (int i = 2; i <= N; i++) {
int k1, k2;
cout << "? " << maxim_idx << " "<<i << endl;
cout.flush();
cin >> k1;
cout << "? " << i << " " << maxim_idx << endl;
cout.flush();
cin >> k2;
if (k1 < k2) {
v[i] = k2;
}
else {
v[maxim_idx] = k1;
maxim_idx = i;
}
}
v[maxim_idx] = N;
cout << "! ";
for (int i = 1; i <= N; i++) {
cout << v[i] << " ";
}
cout << endl;
cout.flush();
}