#include <bits/stdc++.h>
#include "art.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define lb lower_bound
#define all(x) (x).begin(), (x).end()
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
void solve(int N) {
set<int> adj[N + 1], rev[N + 1]; int income[N + 1]{0};
for(int l = 1; l <= N; l++) {
vector<int> R;
for(int i = 1; i <= N; i++) {
if(i == l) continue;
R.pb(i);
}
R.pb(l); int k = publish(R), p = k;
for(int i = N - 1; i > 0; i--) {
swap(R[i], R[i - 1]);
k = publish(R);
if(k < p) {
adj[l].insert(R[i]);
rev[R[i]].insert(l);
income[l]++;
}
else {
adj[R[i]].insert(l);
rev[l].insert(R[i]);
income[R[i]]++;
}
p = k;
}
}
bool vis[N + 1]{0}; vector<int> R; queue<int> q;
for(int l = 1; l <= N; l++)
income[l] /= 2;
for(int l = 1; l <= N; l++) {
if(income[l]) continue;
q.push(l); vis[l] = 1;
}
while(!q.empty()) {
int a = q.front(); q.pop(); R.pb(a);
for(auto u : rev[a]) {
income[u] --;
if(vis[u] || income[u] != 0) continue;
vis[u] = 1; q.push(u);
}
}
reverse(all(R)); answer(R);
}
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 |
300 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 |
300 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 |
25 ms |
324 KB |
Output is correct |
10 |
Correct |
26 ms |
352 KB |
Output is correct |
11 |
Correct |
22 ms |
352 KB |
Output is correct |
12 |
Correct |
19 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
300 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 |
22 ms |
344 KB |
Output is correct |
20 |
Correct |
19 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
300 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 |
25 ms |
324 KB |
Output is correct |
10 |
Correct |
26 ms |
352 KB |
Output is correct |
11 |
Correct |
22 ms |
352 KB |
Output is correct |
12 |
Correct |
19 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
300 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 |
22 ms |
344 KB |
Output is correct |
20 |
Correct |
19 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
24 ms |
332 KB |
Output is correct |
23 |
Correct |
20 ms |
452 KB |
Output is correct |
24 |
Correct |
22 ms |
356 KB |
Output is correct |
25 |
Correct |
18 ms |
352 KB |
Output is correct |
26 |
Incorrect |
145 ms |
676 KB |
Not correct |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
300 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 |
25 ms |
324 KB |
Output is correct |
10 |
Correct |
26 ms |
352 KB |
Output is correct |
11 |
Correct |
22 ms |
352 KB |
Output is correct |
12 |
Correct |
19 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
300 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 |
22 ms |
344 KB |
Output is correct |
20 |
Correct |
19 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
24 ms |
332 KB |
Output is correct |
23 |
Correct |
20 ms |
452 KB |
Output is correct |
24 |
Correct |
22 ms |
356 KB |
Output is correct |
25 |
Correct |
18 ms |
352 KB |
Output is correct |
26 |
Incorrect |
145 ms |
676 KB |
Not correct |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
300 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 |
25 ms |
324 KB |
Output is correct |
10 |
Correct |
26 ms |
352 KB |
Output is correct |
11 |
Correct |
22 ms |
352 KB |
Output is correct |
12 |
Correct |
19 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
300 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 |
22 ms |
344 KB |
Output is correct |
20 |
Correct |
19 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
24 ms |
332 KB |
Output is correct |
23 |
Correct |
20 ms |
452 KB |
Output is correct |
24 |
Correct |
22 ms |
356 KB |
Output is correct |
25 |
Correct |
18 ms |
352 KB |
Output is correct |
26 |
Incorrect |
145 ms |
676 KB |
Not correct |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
300 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 |
25 ms |
324 KB |
Output is correct |
10 |
Correct |
26 ms |
352 KB |
Output is correct |
11 |
Correct |
22 ms |
352 KB |
Output is correct |
12 |
Correct |
19 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
300 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 |
22 ms |
344 KB |
Output is correct |
20 |
Correct |
19 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
24 ms |
332 KB |
Output is correct |
23 |
Correct |
20 ms |
452 KB |
Output is correct |
24 |
Correct |
22 ms |
356 KB |
Output is correct |
25 |
Correct |
18 ms |
352 KB |
Output is correct |
26 |
Incorrect |
145 ms |
676 KB |
Not correct |
27 |
Halted |
0 ms |
0 KB |
- |