#include <bits/stdc++.h>
#include <art.h>
using namespace std;
int nPublic;
map<pair<int, int>, bool> dict;
bool compare(int a, int b) {
if (dict.count({a, b})) return dict[{a, b}];
vector<int> ask = {a};
for (int i = 0; i<nPublic; i++) {
if (i+1 == a || i+1 == b) continue;
ask.push_back(i+1);
}
ask.push_back(b);
int AB = publish(ask);
ask[0] = b;
ask[nPublic-1] = a;
int BA = publish(ask);
dict[{a, b}] = AB < BA;
dict[{b, a}] = BA < AB;
return AB < BA;
}
void solve(int n) {
nPublic = n;
vector<int> a;
for (int i=0; i<n; i++) a.push_back(i+1);
sort(a.begin(), a.end(), compare);
answer(a);
}
// signed main() {
// cin.tie(0);
// ios_base::sync_with_stdio(0);
// int n; cin >> n;
// deque<int> a(n);
// for (int i = 0; i<n; i++) cin >> a[i];
// for (int i = 0; i<n; i++) {
// int cnt = 0;
// for (int i = 0; i<n; i++) {
// for (int j = i+1; j<n; j++) {
// if (a[i]>a[j]) cnt++;
// }
// }
// a.push_back(a[0]);
// a.pop_front();
// cout << cnt << "\n";
// }
// return 0;
// }
Compilation message
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
20 | if(v.size() != N) {
| ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
36 | if(v.size() != N) {
| ~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
7 ms |
312 KB |
Output is correct |
10 |
Correct |
10 ms |
316 KB |
Output is correct |
11 |
Correct |
7 ms |
208 KB |
Output is correct |
12 |
Correct |
8 ms |
308 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
7 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
7 ms |
312 KB |
Output is correct |
10 |
Correct |
10 ms |
316 KB |
Output is correct |
11 |
Correct |
7 ms |
208 KB |
Output is correct |
12 |
Correct |
8 ms |
308 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
7 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
0 ms |
208 KB |
Output is correct |
22 |
Correct |
6 ms |
208 KB |
Output is correct |
23 |
Correct |
8 ms |
208 KB |
Output is correct |
24 |
Correct |
6 ms |
208 KB |
Output is correct |
25 |
Correct |
8 ms |
208 KB |
Output is correct |
26 |
Correct |
126 ms |
708 KB |
Output is correct |
27 |
Correct |
74 ms |
420 KB |
Output is correct |
28 |
Incorrect |
127 ms |
492 KB |
Not correct |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
7 ms |
312 KB |
Output is correct |
10 |
Correct |
10 ms |
316 KB |
Output is correct |
11 |
Correct |
7 ms |
208 KB |
Output is correct |
12 |
Correct |
8 ms |
308 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
7 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
0 ms |
208 KB |
Output is correct |
22 |
Correct |
6 ms |
208 KB |
Output is correct |
23 |
Correct |
8 ms |
208 KB |
Output is correct |
24 |
Correct |
6 ms |
208 KB |
Output is correct |
25 |
Correct |
8 ms |
208 KB |
Output is correct |
26 |
Correct |
126 ms |
708 KB |
Output is correct |
27 |
Correct |
74 ms |
420 KB |
Output is correct |
28 |
Incorrect |
127 ms |
492 KB |
Not correct |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
7 ms |
312 KB |
Output is correct |
10 |
Correct |
10 ms |
316 KB |
Output is correct |
11 |
Correct |
7 ms |
208 KB |
Output is correct |
12 |
Correct |
8 ms |
308 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
7 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
0 ms |
208 KB |
Output is correct |
22 |
Correct |
6 ms |
208 KB |
Output is correct |
23 |
Correct |
8 ms |
208 KB |
Output is correct |
24 |
Correct |
6 ms |
208 KB |
Output is correct |
25 |
Correct |
8 ms |
208 KB |
Output is correct |
26 |
Correct |
126 ms |
708 KB |
Output is correct |
27 |
Correct |
74 ms |
420 KB |
Output is correct |
28 |
Incorrect |
127 ms |
492 KB |
Not correct |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
7 ms |
312 KB |
Output is correct |
10 |
Correct |
10 ms |
316 KB |
Output is correct |
11 |
Correct |
7 ms |
208 KB |
Output is correct |
12 |
Correct |
8 ms |
308 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
7 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
0 ms |
208 KB |
Output is correct |
22 |
Correct |
6 ms |
208 KB |
Output is correct |
23 |
Correct |
8 ms |
208 KB |
Output is correct |
24 |
Correct |
6 ms |
208 KB |
Output is correct |
25 |
Correct |
8 ms |
208 KB |
Output is correct |
26 |
Correct |
126 ms |
708 KB |
Output is correct |
27 |
Correct |
74 ms |
420 KB |
Output is correct |
28 |
Incorrect |
127 ms |
492 KB |
Not correct |
29 |
Halted |
0 ms |
0 KB |
- |