#include <bits/stdc++.h>
#include "art.h"
using namespace std;
int n;
vector < int > init;
int inits;
int try_it(int f, int s)
{
int turn = 1, change = 2;
if(f > s)
{
swap(turn, change);
}
vector < int > sf = init;
swap(sf[f-1], sf[s-1]);
int feedback1 = publish(sf);
if(inits > feedback1)
{
turn = change;
}
return turn;
}
vector < int > combine(vector < int > f, vector < int > s)
{
vector < int > res;
int i = 0;
int j = 0;
while(i < f.size() && j < s.size())
{
int el1 = f[i];
int el2 = s[j];
int order = try_it(el1, el2);
if(order == 1)
{
res.push_back(el1);
i ++;
}
else
{
res.push_back(el2);
j ++;
}
}
while(i < f.size())
{
res.push_back(f[i]);
i ++;
}
while(j < s.size())
{
res.push_back(s[j]);
j ++;
}
return res;
}
vector < int > merge_sort(int l, int r)
{
if(l == r)
{
vector < int > v;
v.push_back(l);
return v;
}
int mid = (l + r)/2;
vector < int > fh, sh;
fh = merge_sort(l, mid);
sh = merge_sort(mid+1, r);
return combine(fh, sh);
}
void solve(int N)
{
n = N;
for (int i = 1; i <= n; ++ i)
init.push_back(i);
inits = publish(init);
vector < int > v = merge_sort(1, n);
answer(v);
return;
}
Compilation message
art.cpp: In function 'std::vector<int> combine(std::vector<int>, std::vector<int>)':
art.cpp:31:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | while(i < f.size() && j < s.size())
| ~~^~~~~~~~~~
art.cpp:31:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | while(i < f.size() && j < s.size())
| ~~^~~~~~~~~~
art.cpp:47:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | while(i < f.size())
| ~~^~~~~~~~~~
art.cpp:52:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | while(j < s.size())
| ~~^~~~~~~~~~
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 |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
4 ms |
336 KB |
Output is correct |
10 |
Correct |
3 ms |
336 KB |
Output is correct |
11 |
Correct |
4 ms |
336 KB |
Output is correct |
12 |
Correct |
4 ms |
440 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
3 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
4 ms |
336 KB |
Output is correct |
10 |
Correct |
3 ms |
336 KB |
Output is correct |
11 |
Correct |
4 ms |
336 KB |
Output is correct |
12 |
Correct |
4 ms |
440 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
3 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
504 KB |
Output is correct |
22 |
Correct |
3 ms |
336 KB |
Output is correct |
23 |
Correct |
4 ms |
444 KB |
Output is correct |
24 |
Correct |
4 ms |
440 KB |
Output is correct |
25 |
Correct |
4 ms |
336 KB |
Output is correct |
26 |
Correct |
31 ms |
436 KB |
Output is correct |
27 |
Correct |
37 ms |
504 KB |
Output is correct |
28 |
Correct |
62 ms |
584 KB |
Output is correct |
29 |
Correct |
62 ms |
336 KB |
Output is correct |
30 |
Correct |
54 ms |
584 KB |
Output is correct |
31 |
Correct |
68 ms |
428 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
1 ms |
336 KB |
Output is correct |
37 |
Correct |
1 ms |
336 KB |
Output is correct |
38 |
Correct |
3 ms |
336 KB |
Output is correct |
39 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
4 ms |
336 KB |
Output is correct |
10 |
Correct |
3 ms |
336 KB |
Output is correct |
11 |
Correct |
4 ms |
336 KB |
Output is correct |
12 |
Correct |
4 ms |
440 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
3 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
504 KB |
Output is correct |
22 |
Correct |
3 ms |
336 KB |
Output is correct |
23 |
Correct |
4 ms |
444 KB |
Output is correct |
24 |
Correct |
4 ms |
440 KB |
Output is correct |
25 |
Correct |
4 ms |
336 KB |
Output is correct |
26 |
Correct |
31 ms |
436 KB |
Output is correct |
27 |
Correct |
37 ms |
504 KB |
Output is correct |
28 |
Correct |
62 ms |
584 KB |
Output is correct |
29 |
Correct |
62 ms |
336 KB |
Output is correct |
30 |
Correct |
54 ms |
584 KB |
Output is correct |
31 |
Correct |
68 ms |
428 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
1 ms |
336 KB |
Output is correct |
37 |
Correct |
1 ms |
336 KB |
Output is correct |
38 |
Correct |
3 ms |
336 KB |
Output is correct |
39 |
Correct |
2 ms |
336 KB |
Output is correct |
40 |
Correct |
1 ms |
336 KB |
Output is correct |
41 |
Correct |
5 ms |
336 KB |
Output is correct |
42 |
Correct |
4 ms |
592 KB |
Output is correct |
43 |
Correct |
4 ms |
336 KB |
Output is correct |
44 |
Correct |
3 ms |
336 KB |
Output is correct |
45 |
Correct |
29 ms |
440 KB |
Output is correct |
46 |
Correct |
31 ms |
592 KB |
Output is correct |
47 |
Correct |
54 ms |
428 KB |
Output is correct |
48 |
Correct |
63 ms |
336 KB |
Output is correct |
49 |
Correct |
63 ms |
432 KB |
Output is correct |
50 |
Correct |
54 ms |
584 KB |
Output is correct |
51 |
Correct |
1 ms |
336 KB |
Output is correct |
52 |
Correct |
89 ms |
436 KB |
Output is correct |
53 |
Correct |
92 ms |
584 KB |
Output is correct |
54 |
Correct |
145 ms |
692 KB |
Output is correct |
55 |
Correct |
164 ms |
588 KB |
Output is correct |
56 |
Correct |
151 ms |
504 KB |
Output is correct |
57 |
Correct |
138 ms |
440 KB |
Output is correct |
58 |
Correct |
1 ms |
336 KB |
Output is correct |
59 |
Correct |
1 ms |
336 KB |
Output is correct |
60 |
Correct |
1 ms |
336 KB |
Output is correct |
61 |
Correct |
1 ms |
336 KB |
Output is correct |
62 |
Correct |
1 ms |
336 KB |
Output is correct |
63 |
Correct |
2 ms |
336 KB |
Output is correct |
64 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
4 ms |
336 KB |
Output is correct |
10 |
Correct |
3 ms |
336 KB |
Output is correct |
11 |
Correct |
4 ms |
336 KB |
Output is correct |
12 |
Correct |
4 ms |
440 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
3 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
504 KB |
Output is correct |
22 |
Correct |
3 ms |
336 KB |
Output is correct |
23 |
Correct |
4 ms |
444 KB |
Output is correct |
24 |
Correct |
4 ms |
440 KB |
Output is correct |
25 |
Correct |
4 ms |
336 KB |
Output is correct |
26 |
Correct |
31 ms |
436 KB |
Output is correct |
27 |
Correct |
37 ms |
504 KB |
Output is correct |
28 |
Correct |
62 ms |
584 KB |
Output is correct |
29 |
Correct |
62 ms |
336 KB |
Output is correct |
30 |
Correct |
54 ms |
584 KB |
Output is correct |
31 |
Correct |
68 ms |
428 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
1 ms |
336 KB |
Output is correct |
37 |
Correct |
1 ms |
336 KB |
Output is correct |
38 |
Correct |
3 ms |
336 KB |
Output is correct |
39 |
Correct |
2 ms |
336 KB |
Output is correct |
40 |
Correct |
1 ms |
336 KB |
Output is correct |
41 |
Correct |
5 ms |
336 KB |
Output is correct |
42 |
Correct |
4 ms |
592 KB |
Output is correct |
43 |
Correct |
4 ms |
336 KB |
Output is correct |
44 |
Correct |
3 ms |
336 KB |
Output is correct |
45 |
Correct |
29 ms |
440 KB |
Output is correct |
46 |
Correct |
31 ms |
592 KB |
Output is correct |
47 |
Correct |
54 ms |
428 KB |
Output is correct |
48 |
Correct |
63 ms |
336 KB |
Output is correct |
49 |
Correct |
63 ms |
432 KB |
Output is correct |
50 |
Correct |
54 ms |
584 KB |
Output is correct |
51 |
Correct |
1 ms |
336 KB |
Output is correct |
52 |
Correct |
89 ms |
436 KB |
Output is correct |
53 |
Correct |
92 ms |
584 KB |
Output is correct |
54 |
Correct |
145 ms |
692 KB |
Output is correct |
55 |
Correct |
164 ms |
588 KB |
Output is correct |
56 |
Correct |
151 ms |
504 KB |
Output is correct |
57 |
Correct |
138 ms |
440 KB |
Output is correct |
58 |
Correct |
1 ms |
336 KB |
Output is correct |
59 |
Correct |
1 ms |
336 KB |
Output is correct |
60 |
Correct |
1 ms |
336 KB |
Output is correct |
61 |
Correct |
1 ms |
336 KB |
Output is correct |
62 |
Correct |
1 ms |
336 KB |
Output is correct |
63 |
Correct |
2 ms |
336 KB |
Output is correct |
64 |
Correct |
2 ms |
336 KB |
Output is correct |
65 |
Correct |
1 ms |
336 KB |
Output is correct |
66 |
Correct |
3 ms |
336 KB |
Output is correct |
67 |
Correct |
3 ms |
336 KB |
Output is correct |
68 |
Correct |
4 ms |
592 KB |
Output is correct |
69 |
Correct |
3 ms |
336 KB |
Output is correct |
70 |
Correct |
30 ms |
444 KB |
Output is correct |
71 |
Correct |
30 ms |
336 KB |
Output is correct |
72 |
Correct |
56 ms |
584 KB |
Output is correct |
73 |
Correct |
54 ms |
432 KB |
Output is correct |
74 |
Correct |
56 ms |
432 KB |
Output is correct |
75 |
Correct |
58 ms |
336 KB |
Output is correct |
76 |
Correct |
1 ms |
508 KB |
Output is correct |
77 |
Correct |
99 ms |
692 KB |
Output is correct |
78 |
Correct |
83 ms |
444 KB |
Output is correct |
79 |
Correct |
141 ms |
436 KB |
Output is correct |
80 |
Correct |
159 ms |
432 KB |
Output is correct |
81 |
Correct |
140 ms |
584 KB |
Output is correct |
82 |
Correct |
145 ms |
588 KB |
Output is correct |
83 |
Incorrect |
716 ms |
1648 KB |
Not correct |
84 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
4 ms |
336 KB |
Output is correct |
10 |
Correct |
3 ms |
336 KB |
Output is correct |
11 |
Correct |
4 ms |
336 KB |
Output is correct |
12 |
Correct |
4 ms |
440 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
3 ms |
592 KB |
Output is correct |
20 |
Correct |
3 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
504 KB |
Output is correct |
22 |
Correct |
3 ms |
336 KB |
Output is correct |
23 |
Correct |
4 ms |
444 KB |
Output is correct |
24 |
Correct |
4 ms |
440 KB |
Output is correct |
25 |
Correct |
4 ms |
336 KB |
Output is correct |
26 |
Correct |
31 ms |
436 KB |
Output is correct |
27 |
Correct |
37 ms |
504 KB |
Output is correct |
28 |
Correct |
62 ms |
584 KB |
Output is correct |
29 |
Correct |
62 ms |
336 KB |
Output is correct |
30 |
Correct |
54 ms |
584 KB |
Output is correct |
31 |
Correct |
68 ms |
428 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
1 ms |
336 KB |
Output is correct |
37 |
Correct |
1 ms |
336 KB |
Output is correct |
38 |
Correct |
3 ms |
336 KB |
Output is correct |
39 |
Correct |
2 ms |
336 KB |
Output is correct |
40 |
Correct |
1 ms |
336 KB |
Output is correct |
41 |
Correct |
5 ms |
336 KB |
Output is correct |
42 |
Correct |
4 ms |
592 KB |
Output is correct |
43 |
Correct |
4 ms |
336 KB |
Output is correct |
44 |
Correct |
3 ms |
336 KB |
Output is correct |
45 |
Correct |
29 ms |
440 KB |
Output is correct |
46 |
Correct |
31 ms |
592 KB |
Output is correct |
47 |
Correct |
54 ms |
428 KB |
Output is correct |
48 |
Correct |
63 ms |
336 KB |
Output is correct |
49 |
Correct |
63 ms |
432 KB |
Output is correct |
50 |
Correct |
54 ms |
584 KB |
Output is correct |
51 |
Correct |
1 ms |
336 KB |
Output is correct |
52 |
Correct |
89 ms |
436 KB |
Output is correct |
53 |
Correct |
92 ms |
584 KB |
Output is correct |
54 |
Correct |
145 ms |
692 KB |
Output is correct |
55 |
Correct |
164 ms |
588 KB |
Output is correct |
56 |
Correct |
151 ms |
504 KB |
Output is correct |
57 |
Correct |
138 ms |
440 KB |
Output is correct |
58 |
Correct |
1 ms |
336 KB |
Output is correct |
59 |
Correct |
1 ms |
336 KB |
Output is correct |
60 |
Correct |
1 ms |
336 KB |
Output is correct |
61 |
Correct |
1 ms |
336 KB |
Output is correct |
62 |
Correct |
1 ms |
336 KB |
Output is correct |
63 |
Correct |
2 ms |
336 KB |
Output is correct |
64 |
Correct |
2 ms |
336 KB |
Output is correct |
65 |
Correct |
1 ms |
336 KB |
Output is correct |
66 |
Correct |
3 ms |
336 KB |
Output is correct |
67 |
Correct |
3 ms |
336 KB |
Output is correct |
68 |
Correct |
4 ms |
592 KB |
Output is correct |
69 |
Correct |
3 ms |
336 KB |
Output is correct |
70 |
Correct |
30 ms |
444 KB |
Output is correct |
71 |
Correct |
30 ms |
336 KB |
Output is correct |
72 |
Correct |
56 ms |
584 KB |
Output is correct |
73 |
Correct |
54 ms |
432 KB |
Output is correct |
74 |
Correct |
56 ms |
432 KB |
Output is correct |
75 |
Correct |
58 ms |
336 KB |
Output is correct |
76 |
Correct |
1 ms |
508 KB |
Output is correct |
77 |
Correct |
99 ms |
692 KB |
Output is correct |
78 |
Correct |
83 ms |
444 KB |
Output is correct |
79 |
Correct |
141 ms |
436 KB |
Output is correct |
80 |
Correct |
159 ms |
432 KB |
Output is correct |
81 |
Correct |
140 ms |
584 KB |
Output is correct |
82 |
Correct |
145 ms |
588 KB |
Output is correct |
83 |
Incorrect |
716 ms |
1648 KB |
Not correct |
84 |
Halted |
0 ms |
0 KB |
- |