답안 #603306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
603306 2022-07-23T23:48:38 Z DanerZein Art Collections (BOI22_art) C++17
50 / 100
863 ms 32136 KB
#include "art.h"
#include <bits/stdc++.h>
using namespace std;

map<vector<int>,int> que;
int cost(vector<int> x,int i,int j){
  swap(x[i],x[j]);
  if(que.find(x)!=que.end()) return que[x];
  return que[x]=publish(x);
}
void printA(vector<int> &y){
  for(int i=0;i<y.size();i++) cout<<y[i]<<" ";
  cout<<endl;
}
int ori;
vector<int> ord;
vector<int> merge_sort(vector<int> x){
  if(x.size()==1) return x;
  vector<int> m1,m2;
  for(int i=0;i<x.size()/2;i++) m1.push_back(x[i]);
  for(int i=x.size()/2;i<x.size();i++) m2.push_back(x[i]);
  m1=merge_sort(m1);
  m2=merge_sort(m2);
  vector<int> o;
  int i=0,j=0;
  while(i!=m1.size() || j!=m2.size()){
    if(i==m1.size()){
      o.push_back(m2[j]); j++;
      continue;
    }
    if(j==m2.size()){
      o.push_back(m1[i]); i++;
      continue;
    }
    if(cost(ord,m1[i]-1,m2[j]-1)>ori){
      o.push_back(m1[i]);
      i++;
    }
    else {
      o.push_back(m2[j]);
      j++;
    }
  }
  return o;
}
void solve(int N) {
  for(int i=1;i<=N;i++) ord.push_back(i);
  ori=publish(ord);
  ord=merge_sort(ord);
  answer(ord);
}

Compilation message

art.cpp: In function 'void printA(std::vector<int>&)':
art.cpp:12:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   for(int i=0;i<y.size();i++) cout<<y[i]<<" ";
      |               ~^~~~~~~~~
art.cpp: In function 'std::vector<int> merge_sort(std::vector<int>)':
art.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i=0;i<x.size()/2;i++) m1.push_back(x[i]);
      |               ~^~~~~~~~~~~
art.cpp:21:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for(int i=x.size()/2;i<x.size();i++) m2.push_back(x[i]);
      |                        ~^~~~~~~~~
art.cpp:26:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   while(i!=m1.size() || j!=m2.size()){
      |         ~^~~~~~~~~~~
art.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   while(i!=m1.size() || j!=m2.size()){
      |                         ~^~~~~~~~~~~
art.cpp:27:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     if(i==m1.size()){
      |        ~^~~~~~~~~~~
art.cpp:31:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     if(j==m2.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 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 0 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 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 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 0 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 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 3 ms 336 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 2 ms 208 KB Output is correct
20 Correct 2 ms 208 KB Output is correct
# 결과 실행 시간 메모리 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 0 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 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 3 ms 336 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 2 ms 208 KB Output is correct
20 Correct 2 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 4 ms 288 KB Output is correct
26 Correct 35 ms 1328 KB Output is correct
27 Correct 34 ms 1256 KB Output is correct
28 Correct 54 ms 1968 KB Output is correct
29 Correct 61 ms 2064 KB Output is correct
30 Correct 58 ms 2236 KB Output is correct
31 Correct 60 ms 2068 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 208 KB Output is correct
35 Correct 0 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 2 ms 300 KB Output is correct
39 Correct 2 ms 208 KB Output is correct
# 결과 실행 시간 메모리 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 0 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 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 3 ms 336 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 2 ms 208 KB Output is correct
20 Correct 2 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 4 ms 288 KB Output is correct
26 Correct 35 ms 1328 KB Output is correct
27 Correct 34 ms 1256 KB Output is correct
28 Correct 54 ms 1968 KB Output is correct
29 Correct 61 ms 2064 KB Output is correct
30 Correct 58 ms 2236 KB Output is correct
31 Correct 60 ms 2068 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 208 KB Output is correct
35 Correct 0 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 2 ms 300 KB Output is correct
39 Correct 2 ms 208 KB Output is correct
40 Correct 1 ms 208 KB Output is correct
41 Correct 2 ms 336 KB Output is correct
42 Correct 3 ms 336 KB Output is correct
43 Correct 3 ms 336 KB Output is correct
44 Correct 3 ms 324 KB Output is correct
45 Correct 36 ms 1324 KB Output is correct
46 Correct 36 ms 1260 KB Output is correct
47 Correct 59 ms 2120 KB Output is correct
48 Correct 59 ms 2060 KB Output is correct
49 Correct 55 ms 2056 KB Output is correct
50 Correct 78 ms 1992 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Correct 129 ms 3756 KB Output is correct
53 Correct 122 ms 3956 KB Output is correct
54 Correct 173 ms 6452 KB Output is correct
55 Correct 185 ms 6388 KB Output is correct
56 Correct 194 ms 6336 KB Output is correct
57 Correct 185 ms 6316 KB Output is correct
58 Correct 0 ms 208 KB Output is correct
59 Correct 0 ms 208 KB Output is correct
60 Correct 1 ms 208 KB Output is correct
61 Correct 1 ms 208 KB Output is correct
62 Correct 1 ms 208 KB Output is correct
63 Correct 2 ms 208 KB Output is correct
64 Correct 3 ms 316 KB Output is correct
# 결과 실행 시간 메모리 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 0 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 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 3 ms 336 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 2 ms 208 KB Output is correct
20 Correct 2 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 4 ms 288 KB Output is correct
26 Correct 35 ms 1328 KB Output is correct
27 Correct 34 ms 1256 KB Output is correct
28 Correct 54 ms 1968 KB Output is correct
29 Correct 61 ms 2064 KB Output is correct
30 Correct 58 ms 2236 KB Output is correct
31 Correct 60 ms 2068 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 208 KB Output is correct
35 Correct 0 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 2 ms 300 KB Output is correct
39 Correct 2 ms 208 KB Output is correct
40 Correct 1 ms 208 KB Output is correct
41 Correct 2 ms 336 KB Output is correct
42 Correct 3 ms 336 KB Output is correct
43 Correct 3 ms 336 KB Output is correct
44 Correct 3 ms 324 KB Output is correct
45 Correct 36 ms 1324 KB Output is correct
46 Correct 36 ms 1260 KB Output is correct
47 Correct 59 ms 2120 KB Output is correct
48 Correct 59 ms 2060 KB Output is correct
49 Correct 55 ms 2056 KB Output is correct
50 Correct 78 ms 1992 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Correct 129 ms 3756 KB Output is correct
53 Correct 122 ms 3956 KB Output is correct
54 Correct 173 ms 6452 KB Output is correct
55 Correct 185 ms 6388 KB Output is correct
56 Correct 194 ms 6336 KB Output is correct
57 Correct 185 ms 6316 KB Output is correct
58 Correct 0 ms 208 KB Output is correct
59 Correct 0 ms 208 KB Output is correct
60 Correct 1 ms 208 KB Output is correct
61 Correct 1 ms 208 KB Output is correct
62 Correct 1 ms 208 KB Output is correct
63 Correct 2 ms 208 KB Output is correct
64 Correct 3 ms 316 KB Output is correct
65 Correct 0 ms 208 KB Output is correct
66 Correct 2 ms 336 KB Output is correct
67 Correct 3 ms 336 KB Output is correct
68 Correct 3 ms 308 KB Output is correct
69 Correct 2 ms 336 KB Output is correct
70 Correct 32 ms 1244 KB Output is correct
71 Correct 47 ms 1332 KB Output is correct
72 Correct 55 ms 2112 KB Output is correct
73 Correct 59 ms 2068 KB Output is correct
74 Correct 58 ms 1992 KB Output is correct
75 Correct 56 ms 1976 KB Output is correct
76 Correct 1 ms 208 KB Output is correct
77 Correct 113 ms 3700 KB Output is correct
78 Correct 112 ms 3988 KB Output is correct
79 Correct 188 ms 6448 KB Output is correct
80 Correct 184 ms 6624 KB Output is correct
81 Correct 193 ms 6456 KB Output is correct
82 Correct 167 ms 6308 KB Output is correct
83 Incorrect 863 ms 32136 KB Not correct
84 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 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 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 3 ms 336 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 2 ms 208 KB Output is correct
20 Correct 2 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 4 ms 288 KB Output is correct
26 Correct 35 ms 1328 KB Output is correct
27 Correct 34 ms 1256 KB Output is correct
28 Correct 54 ms 1968 KB Output is correct
29 Correct 61 ms 2064 KB Output is correct
30 Correct 58 ms 2236 KB Output is correct
31 Correct 60 ms 2068 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 208 KB Output is correct
35 Correct 0 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 2 ms 300 KB Output is correct
39 Correct 2 ms 208 KB Output is correct
40 Correct 1 ms 208 KB Output is correct
41 Correct 2 ms 336 KB Output is correct
42 Correct 3 ms 336 KB Output is correct
43 Correct 3 ms 336 KB Output is correct
44 Correct 3 ms 324 KB Output is correct
45 Correct 36 ms 1324 KB Output is correct
46 Correct 36 ms 1260 KB Output is correct
47 Correct 59 ms 2120 KB Output is correct
48 Correct 59 ms 2060 KB Output is correct
49 Correct 55 ms 2056 KB Output is correct
50 Correct 78 ms 1992 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Correct 129 ms 3756 KB Output is correct
53 Correct 122 ms 3956 KB Output is correct
54 Correct 173 ms 6452 KB Output is correct
55 Correct 185 ms 6388 KB Output is correct
56 Correct 194 ms 6336 KB Output is correct
57 Correct 185 ms 6316 KB Output is correct
58 Correct 0 ms 208 KB Output is correct
59 Correct 0 ms 208 KB Output is correct
60 Correct 1 ms 208 KB Output is correct
61 Correct 1 ms 208 KB Output is correct
62 Correct 1 ms 208 KB Output is correct
63 Correct 2 ms 208 KB Output is correct
64 Correct 3 ms 316 KB Output is correct
65 Correct 0 ms 208 KB Output is correct
66 Correct 2 ms 336 KB Output is correct
67 Correct 3 ms 336 KB Output is correct
68 Correct 3 ms 308 KB Output is correct
69 Correct 2 ms 336 KB Output is correct
70 Correct 32 ms 1244 KB Output is correct
71 Correct 47 ms 1332 KB Output is correct
72 Correct 55 ms 2112 KB Output is correct
73 Correct 59 ms 2068 KB Output is correct
74 Correct 58 ms 1992 KB Output is correct
75 Correct 56 ms 1976 KB Output is correct
76 Correct 1 ms 208 KB Output is correct
77 Correct 113 ms 3700 KB Output is correct
78 Correct 112 ms 3988 KB Output is correct
79 Correct 188 ms 6448 KB Output is correct
80 Correct 184 ms 6624 KB Output is correct
81 Correct 193 ms 6456 KB Output is correct
82 Correct 167 ms 6308 KB Output is correct
83 Incorrect 863 ms 32136 KB Not correct
84 Halted 0 ms 0 KB -