답안 #850789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850789 2023-09-17T12:44:57 Z emad234 Art Collections (BOI22_art) C++17
100 / 100
1338 ms 174360 KB
#include <bits/stdc++.h>
#define all(v) ((v).begin(),(v).end())
#define ll long long
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll mxN = 1e5 + 2;
using namespace std;
// void __attribute__((noreturn)) __attribute__((format(printf, 1, 2))) result(const char *msg, ...) {
//   va_list args;
//   va_start(args, msg);
//   vfprintf(stdout, msg, args);
//   fprintf(stdout, "\n");
//   va_end(args);
//   exit(0);
// }
// 
// namespace {
//   int N;
//   int Q = 0;
//   const int MAX_Q = 4000;
//   const int MAX_N = 4000;
//   vector<int> solution;
// }  // namespace
// 
// 
// void __attribute__((noreturn)) answer(vector<int> R) {
//   printf("answer({");
//   for(int i = 0; i < int(R.size()); ++i) {
//     if(i == 0)
//     printf("%d", R[i]);
//     else
//     printf(", %d", R[i]);
//   }
//   printf("})\n");
//   fflush(stdout);
// 
// 
//   if(R == solution)
//   result("Correct: %d published ranking(s).", Q);
//   else
//   result("Wrong answer!");
// }

int publish(vector<int> R);
  // printf("publish({");
  // for(int i = 0; i < int(R.size()); ++i) {
  //   if(i == 0)
  //   printf("%d", R[i]);
  //   else
  //   printf(", %d", R[i]);
  // }
  // printf("})\n");
  // fflush(stdout);
// 
//   if (++Q > MAX_Q)
//   result("Too many published rankings!");
// 
//   if (int(R.size()) != N)
//   result("Invalid published ranking!");
// 
//   set<int> chosen;
//   for(auto &x : R) {
//     if(x < 1 || x > N || chosen.count(x))
//     result("Invalid published ranking!");
//     chosen.insert(x);
//   }
//   vector<int> positions(N+1);
//   for(int i = 0; i < N; ++i)
//   positions[R[i]] = i;
// 
//   int complaints = 0;
//   for(int i = 0; i < N; ++i) {
//     for(int j = i+1; j < N; ++j) {
//       if(positions[solution[i]] > positions[solution[j]])
//       ++complaints;
//     }
//   }
// 
//   return complaints;
// }

void answer(std::vector<int>);
struct number{
  int val;
  vector<int>v;
};
number A[mxN],B[mxN];
vector<int>ans;
void calc(int i,int N){
  int x = A[i].val,y = B[i].val;
  int c = (x + y - (N - 1))/2;
  x -= c;
  y -= c;
  ans[x] = i;
}
void cont(int i,int j,int N){
  if(i > j) return;
  if(i == j){
    calc(i,N);
    return;
  }
  vector<int>b = A[i].v;
  vector<int>a = {j};
  for(auto x : B[j].v){
    a.push_back(x);
  }
  b.push_back(i);
  int x = publish(b),y = publish(a);
  vector<int>temp;
  for(auto x : b){
    if(x != i + 1) temp.push_back(x);
  }
  a.pop_back();
  B[i].val = x;
  A[j].val = y;
  A[i + 1].val = x;
  A[i + 1].v = temp;
  B[j - 1].val = y;
  B[j - 1].v = a;
  calc(i,N);calc(j,N);
  cont(i + 1,j - 1,N);
}
void solve(int N) {
  ans.resize(N);
    for(int i = 1;i <= N;i++){
      A[i].val = -1;
      B[i].val = -1;
    }
    vector<int>a = {1},b;
    for(auto j = 1;j <= N;j++){
      if(j != 1) {
        a.push_back(j);
        b.push_back(j);
      }
    }
    b.push_back(1);
    int x = publish(a),y = publish(b);
    a.pop_back();
    vector<int>temp;
    for(auto x : b){
      if(x != 2) temp.push_back(x);
    }
    B[N].val = x;
    B[N].v = a;
    A[2].val = y;
    A[2].v = temp;
    A[1].val = x;
    B[1].val = y;
    calc(1,N);
    cont(2,N,N);
    answer(ans);
}
// 
// int main() {
//     if (scanf("%d", &N) != 1 || N < 2 || N > MAX_N)
//         result("Invalid input!");
// 
//     solution.resize(N);
//     set<int> chosen;
//     for(auto &x : solution) {
//         if(scanf("%d", &x) != 1 || x < 1 || x > N || chosen.count(x))
//             result("Invalid input!");
//         chosen.insert(x);
//     }
// 
//     solve(N);
// 
//     result("No answer!");
// }

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) {
      |        ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 3 ms 6744 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6484 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 3 ms 6744 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6484 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 3 ms 6932 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 3 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 2 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6488 KB Output is correct
20 Correct 2 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 3 ms 6744 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6484 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 3 ms 6932 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 3 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 2 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6488 KB Output is correct
20 Correct 2 ms 6744 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 2 ms 6488 KB Output is correct
23 Correct 3 ms 6744 KB Output is correct
24 Correct 3 ms 6488 KB Output is correct
25 Correct 2 ms 6488 KB Output is correct
26 Correct 8 ms 7480 KB Output is correct
27 Correct 8 ms 8496 KB Output is correct
28 Correct 10 ms 7864 KB Output is correct
29 Correct 9 ms 7628 KB Output is correct
30 Correct 8 ms 7628 KB Output is correct
31 Correct 9 ms 7748 KB Output is correct
32 Correct 2 ms 6488 KB Output is correct
33 Correct 2 ms 6488 KB Output is correct
34 Correct 2 ms 6488 KB Output is correct
35 Correct 2 ms 6488 KB Output is correct
36 Correct 2 ms 6488 KB Output is correct
37 Correct 2 ms 6488 KB Output is correct
38 Correct 2 ms 6736 KB Output is correct
39 Correct 2 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 3 ms 6744 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6484 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 3 ms 6932 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 3 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 2 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6488 KB Output is correct
20 Correct 2 ms 6744 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 2 ms 6488 KB Output is correct
23 Correct 3 ms 6744 KB Output is correct
24 Correct 3 ms 6488 KB Output is correct
25 Correct 2 ms 6488 KB Output is correct
26 Correct 8 ms 7480 KB Output is correct
27 Correct 8 ms 8496 KB Output is correct
28 Correct 10 ms 7864 KB Output is correct
29 Correct 9 ms 7628 KB Output is correct
30 Correct 8 ms 7628 KB Output is correct
31 Correct 9 ms 7748 KB Output is correct
32 Correct 2 ms 6488 KB Output is correct
33 Correct 2 ms 6488 KB Output is correct
34 Correct 2 ms 6488 KB Output is correct
35 Correct 2 ms 6488 KB Output is correct
36 Correct 2 ms 6488 KB Output is correct
37 Correct 2 ms 6488 KB Output is correct
38 Correct 2 ms 6736 KB Output is correct
39 Correct 2 ms 6744 KB Output is correct
40 Correct 2 ms 6488 KB Output is correct
41 Correct 2 ms 6744 KB Output is correct
42 Correct 2 ms 6488 KB Output is correct
43 Correct 2 ms 6488 KB Output is correct
44 Correct 2 ms 6488 KB Output is correct
45 Correct 8 ms 8064 KB Output is correct
46 Correct 8 ms 7732 KB Output is correct
47 Correct 8 ms 7728 KB Output is correct
48 Correct 9 ms 7476 KB Output is correct
49 Correct 8 ms 8248 KB Output is correct
50 Correct 8 ms 7732 KB Output is correct
51 Correct 2 ms 6488 KB Output is correct
52 Correct 21 ms 10044 KB Output is correct
53 Correct 19 ms 9464 KB Output is correct
54 Correct 24 ms 9588 KB Output is correct
55 Correct 20 ms 9780 KB Output is correct
56 Correct 20 ms 9404 KB Output is correct
57 Correct 20 ms 9400 KB Output is correct
58 Correct 2 ms 6488 KB Output is correct
59 Correct 2 ms 6488 KB Output is correct
60 Correct 2 ms 6488 KB Output is correct
61 Correct 2 ms 6488 KB Output is correct
62 Correct 2 ms 6488 KB Output is correct
63 Correct 2 ms 6488 KB Output is correct
64 Correct 2 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 3 ms 6744 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6484 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 3 ms 6932 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 3 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 2 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6488 KB Output is correct
20 Correct 2 ms 6744 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 2 ms 6488 KB Output is correct
23 Correct 3 ms 6744 KB Output is correct
24 Correct 3 ms 6488 KB Output is correct
25 Correct 2 ms 6488 KB Output is correct
26 Correct 8 ms 7480 KB Output is correct
27 Correct 8 ms 8496 KB Output is correct
28 Correct 10 ms 7864 KB Output is correct
29 Correct 9 ms 7628 KB Output is correct
30 Correct 8 ms 7628 KB Output is correct
31 Correct 9 ms 7748 KB Output is correct
32 Correct 2 ms 6488 KB Output is correct
33 Correct 2 ms 6488 KB Output is correct
34 Correct 2 ms 6488 KB Output is correct
35 Correct 2 ms 6488 KB Output is correct
36 Correct 2 ms 6488 KB Output is correct
37 Correct 2 ms 6488 KB Output is correct
38 Correct 2 ms 6736 KB Output is correct
39 Correct 2 ms 6744 KB Output is correct
40 Correct 2 ms 6488 KB Output is correct
41 Correct 2 ms 6744 KB Output is correct
42 Correct 2 ms 6488 KB Output is correct
43 Correct 2 ms 6488 KB Output is correct
44 Correct 2 ms 6488 KB Output is correct
45 Correct 8 ms 8064 KB Output is correct
46 Correct 8 ms 7732 KB Output is correct
47 Correct 8 ms 7728 KB Output is correct
48 Correct 9 ms 7476 KB Output is correct
49 Correct 8 ms 8248 KB Output is correct
50 Correct 8 ms 7732 KB Output is correct
51 Correct 2 ms 6488 KB Output is correct
52 Correct 21 ms 10044 KB Output is correct
53 Correct 19 ms 9464 KB Output is correct
54 Correct 24 ms 9588 KB Output is correct
55 Correct 20 ms 9780 KB Output is correct
56 Correct 20 ms 9404 KB Output is correct
57 Correct 20 ms 9400 KB Output is correct
58 Correct 2 ms 6488 KB Output is correct
59 Correct 2 ms 6488 KB Output is correct
60 Correct 2 ms 6488 KB Output is correct
61 Correct 2 ms 6488 KB Output is correct
62 Correct 2 ms 6488 KB Output is correct
63 Correct 2 ms 6488 KB Output is correct
64 Correct 2 ms 6488 KB Output is correct
65 Correct 2 ms 6488 KB Output is correct
66 Correct 2 ms 6572 KB Output is correct
67 Correct 2 ms 6488 KB Output is correct
68 Correct 2 ms 6780 KB Output is correct
69 Correct 2 ms 6488 KB Output is correct
70 Correct 10 ms 7840 KB Output is correct
71 Correct 8 ms 8212 KB Output is correct
72 Correct 8 ms 7728 KB Output is correct
73 Correct 8 ms 7984 KB Output is correct
74 Correct 8 ms 8172 KB Output is correct
75 Correct 9 ms 7476 KB Output is correct
76 Correct 2 ms 6488 KB Output is correct
77 Correct 20 ms 9312 KB Output is correct
78 Correct 21 ms 9556 KB Output is correct
79 Correct 22 ms 9488 KB Output is correct
80 Correct 20 ms 9628 KB Output is correct
81 Correct 20 ms 9436 KB Output is correct
82 Correct 20 ms 9328 KB Output is correct
83 Correct 331 ms 51308 KB Output is correct
84 Correct 329 ms 50876 KB Output is correct
85 Correct 332 ms 50844 KB Output is correct
86 Correct 328 ms 50680 KB Output is correct
87 Correct 2 ms 6488 KB Output is correct
88 Correct 330 ms 50968 KB Output is correct
89 Correct 336 ms 51124 KB Output is correct
90 Correct 2 ms 6488 KB Output is correct
91 Correct 2 ms 6488 KB Output is correct
92 Correct 2 ms 6488 KB Output is correct
93 Correct 2 ms 6488 KB Output is correct
94 Correct 2 ms 6488 KB Output is correct
95 Correct 2 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 3 ms 6744 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6484 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 3 ms 6932 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 3 ms 6488 KB Output is correct
15 Correct 2 ms 6488 KB Output is correct
16 Correct 2 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6488 KB Output is correct
20 Correct 2 ms 6744 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 2 ms 6488 KB Output is correct
23 Correct 3 ms 6744 KB Output is correct
24 Correct 3 ms 6488 KB Output is correct
25 Correct 2 ms 6488 KB Output is correct
26 Correct 8 ms 7480 KB Output is correct
27 Correct 8 ms 8496 KB Output is correct
28 Correct 10 ms 7864 KB Output is correct
29 Correct 9 ms 7628 KB Output is correct
30 Correct 8 ms 7628 KB Output is correct
31 Correct 9 ms 7748 KB Output is correct
32 Correct 2 ms 6488 KB Output is correct
33 Correct 2 ms 6488 KB Output is correct
34 Correct 2 ms 6488 KB Output is correct
35 Correct 2 ms 6488 KB Output is correct
36 Correct 2 ms 6488 KB Output is correct
37 Correct 2 ms 6488 KB Output is correct
38 Correct 2 ms 6736 KB Output is correct
39 Correct 2 ms 6744 KB Output is correct
40 Correct 2 ms 6488 KB Output is correct
41 Correct 2 ms 6744 KB Output is correct
42 Correct 2 ms 6488 KB Output is correct
43 Correct 2 ms 6488 KB Output is correct
44 Correct 2 ms 6488 KB Output is correct
45 Correct 8 ms 8064 KB Output is correct
46 Correct 8 ms 7732 KB Output is correct
47 Correct 8 ms 7728 KB Output is correct
48 Correct 9 ms 7476 KB Output is correct
49 Correct 8 ms 8248 KB Output is correct
50 Correct 8 ms 7732 KB Output is correct
51 Correct 2 ms 6488 KB Output is correct
52 Correct 21 ms 10044 KB Output is correct
53 Correct 19 ms 9464 KB Output is correct
54 Correct 24 ms 9588 KB Output is correct
55 Correct 20 ms 9780 KB Output is correct
56 Correct 20 ms 9404 KB Output is correct
57 Correct 20 ms 9400 KB Output is correct
58 Correct 2 ms 6488 KB Output is correct
59 Correct 2 ms 6488 KB Output is correct
60 Correct 2 ms 6488 KB Output is correct
61 Correct 2 ms 6488 KB Output is correct
62 Correct 2 ms 6488 KB Output is correct
63 Correct 2 ms 6488 KB Output is correct
64 Correct 2 ms 6488 KB Output is correct
65 Correct 2 ms 6488 KB Output is correct
66 Correct 2 ms 6572 KB Output is correct
67 Correct 2 ms 6488 KB Output is correct
68 Correct 2 ms 6780 KB Output is correct
69 Correct 2 ms 6488 KB Output is correct
70 Correct 10 ms 7840 KB Output is correct
71 Correct 8 ms 8212 KB Output is correct
72 Correct 8 ms 7728 KB Output is correct
73 Correct 8 ms 7984 KB Output is correct
74 Correct 8 ms 8172 KB Output is correct
75 Correct 9 ms 7476 KB Output is correct
76 Correct 2 ms 6488 KB Output is correct
77 Correct 20 ms 9312 KB Output is correct
78 Correct 21 ms 9556 KB Output is correct
79 Correct 22 ms 9488 KB Output is correct
80 Correct 20 ms 9628 KB Output is correct
81 Correct 20 ms 9436 KB Output is correct
82 Correct 20 ms 9328 KB Output is correct
83 Correct 331 ms 51308 KB Output is correct
84 Correct 329 ms 50876 KB Output is correct
85 Correct 332 ms 50844 KB Output is correct
86 Correct 328 ms 50680 KB Output is correct
87 Correct 2 ms 6488 KB Output is correct
88 Correct 330 ms 50968 KB Output is correct
89 Correct 336 ms 51124 KB Output is correct
90 Correct 2 ms 6488 KB Output is correct
91 Correct 2 ms 6488 KB Output is correct
92 Correct 2 ms 6488 KB Output is correct
93 Correct 2 ms 6488 KB Output is correct
94 Correct 2 ms 6488 KB Output is correct
95 Correct 2 ms 6488 KB Output is correct
96 Correct 2 ms 6488 KB Output is correct
97 Correct 2 ms 6488 KB Output is correct
98 Correct 2 ms 6488 KB Output is correct
99 Correct 3 ms 6744 KB Output is correct
100 Correct 2 ms 6488 KB Output is correct
101 Correct 8 ms 8056 KB Output is correct
102 Correct 8 ms 7728 KB Output is correct
103 Correct 10 ms 8248 KB Output is correct
104 Correct 8 ms 7992 KB Output is correct
105 Correct 8 ms 7796 KB Output is correct
106 Correct 8 ms 7564 KB Output is correct
107 Correct 2 ms 6488 KB Output is correct
108 Correct 20 ms 9552 KB Output is correct
109 Correct 20 ms 9380 KB Output is correct
110 Correct 20 ms 9320 KB Output is correct
111 Correct 20 ms 9828 KB Output is correct
112 Correct 19 ms 9720 KB Output is correct
113 Correct 19 ms 9144 KB Output is correct
114 Correct 332 ms 51408 KB Output is correct
115 Correct 330 ms 50932 KB Output is correct
116 Correct 329 ms 51364 KB Output is correct
117 Correct 329 ms 51108 KB Output is correct
118 Correct 2 ms 6488 KB Output is correct
119 Correct 330 ms 50996 KB Output is correct
120 Correct 329 ms 51028 KB Output is correct
121 Correct 1292 ms 174360 KB Output is correct
122 Correct 1289 ms 173836 KB Output is correct
123 Correct 1311 ms 173392 KB Output is correct
124 Correct 1327 ms 173864 KB Output is correct
125 Correct 1338 ms 173532 KB Output is correct
126 Correct 1331 ms 173796 KB Output is correct
127 Correct 2 ms 6488 KB Output is correct
128 Correct 2 ms 6488 KB Output is correct
129 Correct 2 ms 6488 KB Output is correct
130 Correct 2 ms 6488 KB Output is correct
131 Correct 3 ms 6488 KB Output is correct
132 Correct 2 ms 6488 KB Output is correct