Submission #598044

# Submission time Handle Problem Language Result Execution time Memory
598044 2022-07-17T12:50:12 Z jhnah917 Art Collections (BOI22_art) C++17
35 / 100
192 ms 288 KB
#include "art.h"
#include <bits/stdc++.h>
using namespace std;

bool compare(vector<int> &ord, int a, int b){
    if(a == b) return false;
    int pa = find(ord.begin(), ord.end(), a) - ord.begin();
    int pb = find(ord.begin(), ord.end(), b) - ord.begin();
    int t1 = publish(ord);
    swap(ord[pa], ord[pb]);
    int t2 = publish(ord);
    swap(ord[pa], ord[pb]);
    return t1 < t2;
}

void merge_sort(vector<int> &ord, int s, int e){
    if(s >= e) return;
    int m = (s + e) / 2;
    merge_sort(ord, s, m);
    merge_sort(ord, m+1, e);

    vector<int> tmp(ord.size());
    int i = s, j = m+1, k = s;
    while(i <= m && j <= e){
        if(compare(ord, ord[i], ord[j])) tmp[k++] = ord[i++];
        else tmp[k++] = ord[j++];
    }
    while(i <= m) tmp[k++] = ord[i++];
    while(j <= e) tmp[k++] = ord[j++];
    for(k=s; k<=e; k++) ord[k] = tmp[k];
}

void solve(int n){
    vector<int> ord(n);
    iota(ord.begin(), ord.end(), 1);
    merge_sort(ord, 0, n-1);
    answer(ord);
}

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 0 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 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 4 ms 208 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 6 ms 208 KB Output is correct
12 Correct 4 ms 208 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 0 ms 208 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 4 ms 208 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 6 ms 208 KB Output is correct
12 Correct 4 ms 208 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 0 ms 208 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 5 ms 208 KB Output is correct
23 Correct 3 ms 208 KB Output is correct
24 Correct 5 ms 208 KB Output is correct
25 Correct 4 ms 288 KB Output is correct
26 Correct 60 ms 208 KB Output is correct
27 Correct 71 ms 208 KB Output is correct
28 Correct 118 ms 208 KB Output is correct
29 Correct 92 ms 208 KB Output is correct
30 Correct 104 ms 208 KB Output is correct
31 Correct 110 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 3 ms 208 KB Output is correct
39 Correct 3 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 4 ms 208 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 6 ms 208 KB Output is correct
12 Correct 4 ms 208 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 0 ms 208 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 5 ms 208 KB Output is correct
23 Correct 3 ms 208 KB Output is correct
24 Correct 5 ms 208 KB Output is correct
25 Correct 4 ms 288 KB Output is correct
26 Correct 60 ms 208 KB Output is correct
27 Correct 71 ms 208 KB Output is correct
28 Correct 118 ms 208 KB Output is correct
29 Correct 92 ms 208 KB Output is correct
30 Correct 104 ms 208 KB Output is correct
31 Correct 110 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 3 ms 208 KB Output is correct
39 Correct 3 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 6 ms 208 KB Output is correct
42 Correct 4 ms 208 KB Output is correct
43 Correct 6 ms 208 KB Output is correct
44 Correct 5 ms 208 KB Output is correct
45 Correct 63 ms 208 KB Output is correct
46 Correct 59 ms 208 KB Output is correct
47 Correct 95 ms 208 KB Output is correct
48 Correct 102 ms 208 KB Output is correct
49 Correct 98 ms 208 KB Output is correct
50 Correct 100 ms 208 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Incorrect 192 ms 208 KB Not correct
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 4 ms 208 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 6 ms 208 KB Output is correct
12 Correct 4 ms 208 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 0 ms 208 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 5 ms 208 KB Output is correct
23 Correct 3 ms 208 KB Output is correct
24 Correct 5 ms 208 KB Output is correct
25 Correct 4 ms 288 KB Output is correct
26 Correct 60 ms 208 KB Output is correct
27 Correct 71 ms 208 KB Output is correct
28 Correct 118 ms 208 KB Output is correct
29 Correct 92 ms 208 KB Output is correct
30 Correct 104 ms 208 KB Output is correct
31 Correct 110 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 3 ms 208 KB Output is correct
39 Correct 3 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 6 ms 208 KB Output is correct
42 Correct 4 ms 208 KB Output is correct
43 Correct 6 ms 208 KB Output is correct
44 Correct 5 ms 208 KB Output is correct
45 Correct 63 ms 208 KB Output is correct
46 Correct 59 ms 208 KB Output is correct
47 Correct 95 ms 208 KB Output is correct
48 Correct 102 ms 208 KB Output is correct
49 Correct 98 ms 208 KB Output is correct
50 Correct 100 ms 208 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Incorrect 192 ms 208 KB Not correct
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 4 ms 208 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 6 ms 208 KB Output is correct
12 Correct 4 ms 208 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 0 ms 208 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 5 ms 208 KB Output is correct
23 Correct 3 ms 208 KB Output is correct
24 Correct 5 ms 208 KB Output is correct
25 Correct 4 ms 288 KB Output is correct
26 Correct 60 ms 208 KB Output is correct
27 Correct 71 ms 208 KB Output is correct
28 Correct 118 ms 208 KB Output is correct
29 Correct 92 ms 208 KB Output is correct
30 Correct 104 ms 208 KB Output is correct
31 Correct 110 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 3 ms 208 KB Output is correct
39 Correct 3 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 6 ms 208 KB Output is correct
42 Correct 4 ms 208 KB Output is correct
43 Correct 6 ms 208 KB Output is correct
44 Correct 5 ms 208 KB Output is correct
45 Correct 63 ms 208 KB Output is correct
46 Correct 59 ms 208 KB Output is correct
47 Correct 95 ms 208 KB Output is correct
48 Correct 102 ms 208 KB Output is correct
49 Correct 98 ms 208 KB Output is correct
50 Correct 100 ms 208 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Incorrect 192 ms 208 KB Not correct
53 Halted 0 ms 0 KB -