답안 #930928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
930928 2024-02-20T20:17:00 Z Alebn Art Collections (BOI22_art) C++17
35 / 100
141 ms 440 KB
#include <bits/stdc++.h>
#include "art.h"

using namespace std;

int n, x, y, p, q, mid;
vector<int> res;
bool compare(int a, int b) {
    vector<int> q(n);
    q[0] = a, q[1] = b;
    for(int i = 2, j = 1; i < n; i++) {
        if(j == a) j++;
        if(j == b) j++;
        if(j == a) j++;
        q[i] = j;
        j++;
    }
    x = publish(q);
    swap(q[0], q[1]);
    y = publish(q);
    if(x < y) return true;
    return false;
}
void merge(int l, int r) {
    if(l == r) return;
    merge(l, (l + r) / 2);
    merge((l + r) / 2 + 1, r);
    mid = (l + r) / 2;
    vector<int> a(mid - l + 1), b(r - mid);
    for(int k = 0; k <= mid - l; k++) a[k] = res[k + l];
    for(int k = 0; k < r - mid; k++) b[k] = res[k + mid + 1];
    p = 0, q = 0;
    while(p < a.size() && q < b.size()) {
        x = compare(a[p], b[q]);
        if(x) {
            res[l + p + q] = a[p];
            p++;
        } else {
            res[l + p + q] = b[q];
            q++;
        }
    }
    while(p < a.size()) {
        res[l + p + q] = a[p];
        p++;
    }
    while(q < b.size()) {
        res[l + p + q] = b[q];
        q++;
    }
}

void solve(int ni) {
    n = ni, res = vector<int>(n);
    for(int i = 0; i < n; i++) res[i] = i + 1;
    merge(0, n-1);
    answer(res);
}

Compilation message

art.cpp: In function 'void merge(int, int)':
art.cpp:33:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     while(p < a.size() && q < b.size()) {
      |           ~~^~~~~~~~~~
art.cpp:33:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     while(p < a.size() && q < b.size()) {
      |                           ~~^~~~~~~~~~
art.cpp:43:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     while(p < a.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(q < b.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) {
      |        ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 3 ms 344 KB Output is correct
24 Correct 2 ms 344 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 48 ms 344 KB Output is correct
27 Correct 44 ms 344 KB Output is correct
28 Correct 71 ms 344 KB Output is correct
29 Correct 71 ms 344 KB Output is correct
30 Correct 74 ms 344 KB Output is correct
31 Correct 73 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 2 ms 344 KB Output is correct
39 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 3 ms 344 KB Output is correct
24 Correct 2 ms 344 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 48 ms 344 KB Output is correct
27 Correct 44 ms 344 KB Output is correct
28 Correct 71 ms 344 KB Output is correct
29 Correct 71 ms 344 KB Output is correct
30 Correct 74 ms 344 KB Output is correct
31 Correct 73 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 2 ms 344 KB Output is correct
39 Correct 2 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 2 ms 344 KB Output is correct
42 Correct 2 ms 344 KB Output is correct
43 Correct 3 ms 344 KB Output is correct
44 Correct 2 ms 344 KB Output is correct
45 Correct 43 ms 344 KB Output is correct
46 Correct 43 ms 344 KB Output is correct
47 Correct 72 ms 344 KB Output is correct
48 Correct 75 ms 344 KB Output is correct
49 Correct 73 ms 344 KB Output is correct
50 Correct 72 ms 344 KB Output is correct
51 Correct 1 ms 344 KB Output is correct
52 Incorrect 141 ms 440 KB Not correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 3 ms 344 KB Output is correct
24 Correct 2 ms 344 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 48 ms 344 KB Output is correct
27 Correct 44 ms 344 KB Output is correct
28 Correct 71 ms 344 KB Output is correct
29 Correct 71 ms 344 KB Output is correct
30 Correct 74 ms 344 KB Output is correct
31 Correct 73 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 2 ms 344 KB Output is correct
39 Correct 2 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 2 ms 344 KB Output is correct
42 Correct 2 ms 344 KB Output is correct
43 Correct 3 ms 344 KB Output is correct
44 Correct 2 ms 344 KB Output is correct
45 Correct 43 ms 344 KB Output is correct
46 Correct 43 ms 344 KB Output is correct
47 Correct 72 ms 344 KB Output is correct
48 Correct 75 ms 344 KB Output is correct
49 Correct 73 ms 344 KB Output is correct
50 Correct 72 ms 344 KB Output is correct
51 Correct 1 ms 344 KB Output is correct
52 Incorrect 141 ms 440 KB Not correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 3 ms 344 KB Output is correct
24 Correct 2 ms 344 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 48 ms 344 KB Output is correct
27 Correct 44 ms 344 KB Output is correct
28 Correct 71 ms 344 KB Output is correct
29 Correct 71 ms 344 KB Output is correct
30 Correct 74 ms 344 KB Output is correct
31 Correct 73 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 2 ms 344 KB Output is correct
39 Correct 2 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 2 ms 344 KB Output is correct
42 Correct 2 ms 344 KB Output is correct
43 Correct 3 ms 344 KB Output is correct
44 Correct 2 ms 344 KB Output is correct
45 Correct 43 ms 344 KB Output is correct
46 Correct 43 ms 344 KB Output is correct
47 Correct 72 ms 344 KB Output is correct
48 Correct 75 ms 344 KB Output is correct
49 Correct 73 ms 344 KB Output is correct
50 Correct 72 ms 344 KB Output is correct
51 Correct 1 ms 344 KB Output is correct
52 Incorrect 141 ms 440 KB Not correct
53 Halted 0 ms 0 KB -