답안 #850306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850306 2023-09-16T10:04:53 Z vjudge1 Art Collections (BOI22_art) C++17
100 / 100
1329 ms 173884 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 2 ms 6488 KB Output is correct
3 Correct 3 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6488 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 2 ms 6488 KB Output is correct
3 Correct 3 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6488 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 3 ms 6744 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 2 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 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 2 ms 6488 KB Output is correct
3 Correct 3 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6488 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 3 ms 6744 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 2 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 6488 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 2 ms 6488 KB Output is correct
23 Correct 2 ms 6488 KB Output is correct
24 Correct 2 ms 6488 KB Output is correct
25 Correct 3 ms 6488 KB Output is correct
26 Correct 8 ms 7644 KB Output is correct
27 Correct 9 ms 7988 KB Output is correct
28 Correct 8 ms 7764 KB Output is correct
29 Correct 8 ms 7256 KB Output is correct
30 Correct 8 ms 7996 KB Output is correct
31 Correct 8 ms 7476 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 6484 KB Output is correct
35 Correct 2 ms 6488 KB Output is correct
36 Correct 4 ms 6488 KB Output is correct
37 Correct 2 ms 6488 KB Output is correct
38 Correct 3 ms 6744 KB Output is correct
39 Correct 2 ms 6500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 2 ms 6488 KB Output is correct
3 Correct 3 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6488 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 3 ms 6744 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 2 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 6488 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 2 ms 6488 KB Output is correct
23 Correct 2 ms 6488 KB Output is correct
24 Correct 2 ms 6488 KB Output is correct
25 Correct 3 ms 6488 KB Output is correct
26 Correct 8 ms 7644 KB Output is correct
27 Correct 9 ms 7988 KB Output is correct
28 Correct 8 ms 7764 KB Output is correct
29 Correct 8 ms 7256 KB Output is correct
30 Correct 8 ms 7996 KB Output is correct
31 Correct 8 ms 7476 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 6484 KB Output is correct
35 Correct 2 ms 6488 KB Output is correct
36 Correct 4 ms 6488 KB Output is correct
37 Correct 2 ms 6488 KB Output is correct
38 Correct 3 ms 6744 KB Output is correct
39 Correct 2 ms 6500 KB Output is correct
40 Correct 2 ms 6488 KB Output is correct
41 Correct 2 ms 6972 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 7956 KB Output is correct
46 Correct 8 ms 7784 KB Output is correct
47 Correct 8 ms 7524 KB Output is correct
48 Correct 9 ms 7588 KB Output is correct
49 Correct 8 ms 7636 KB Output is correct
50 Correct 9 ms 8012 KB Output is correct
51 Correct 2 ms 6488 KB Output is correct
52 Correct 19 ms 9736 KB Output is correct
53 Correct 20 ms 9768 KB Output is correct
54 Correct 21 ms 9712 KB Output is correct
55 Correct 20 ms 9308 KB Output is correct
56 Correct 20 ms 9356 KB Output is correct
57 Correct 20 ms 9768 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 2 ms 6488 KB Output is correct
3 Correct 3 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6488 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 3 ms 6744 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 2 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 6488 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 2 ms 6488 KB Output is correct
23 Correct 2 ms 6488 KB Output is correct
24 Correct 2 ms 6488 KB Output is correct
25 Correct 3 ms 6488 KB Output is correct
26 Correct 8 ms 7644 KB Output is correct
27 Correct 9 ms 7988 KB Output is correct
28 Correct 8 ms 7764 KB Output is correct
29 Correct 8 ms 7256 KB Output is correct
30 Correct 8 ms 7996 KB Output is correct
31 Correct 8 ms 7476 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 6484 KB Output is correct
35 Correct 2 ms 6488 KB Output is correct
36 Correct 4 ms 6488 KB Output is correct
37 Correct 2 ms 6488 KB Output is correct
38 Correct 3 ms 6744 KB Output is correct
39 Correct 2 ms 6500 KB Output is correct
40 Correct 2 ms 6488 KB Output is correct
41 Correct 2 ms 6972 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 7956 KB Output is correct
46 Correct 8 ms 7784 KB Output is correct
47 Correct 8 ms 7524 KB Output is correct
48 Correct 9 ms 7588 KB Output is correct
49 Correct 8 ms 7636 KB Output is correct
50 Correct 9 ms 8012 KB Output is correct
51 Correct 2 ms 6488 KB Output is correct
52 Correct 19 ms 9736 KB Output is correct
53 Correct 20 ms 9768 KB Output is correct
54 Correct 21 ms 9712 KB Output is correct
55 Correct 20 ms 9308 KB Output is correct
56 Correct 20 ms 9356 KB Output is correct
57 Correct 20 ms 9768 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 6488 KB Output is correct
67 Correct 2 ms 6488 KB Output is correct
68 Correct 3 ms 6744 KB Output is correct
69 Correct 2 ms 6488 KB Output is correct
70 Correct 8 ms 7220 KB Output is correct
71 Correct 8 ms 7476 KB Output is correct
72 Correct 9 ms 7652 KB Output is correct
73 Correct 8 ms 7732 KB Output is correct
74 Correct 8 ms 7732 KB Output is correct
75 Correct 8 ms 8248 KB Output is correct
76 Correct 2 ms 6488 KB Output is correct
77 Correct 20 ms 9172 KB Output is correct
78 Correct 20 ms 9796 KB Output is correct
79 Correct 20 ms 9772 KB Output is correct
80 Correct 21 ms 9664 KB Output is correct
81 Correct 20 ms 9764 KB Output is correct
82 Correct 19 ms 9652 KB Output is correct
83 Correct 335 ms 50716 KB Output is correct
84 Correct 339 ms 50864 KB Output is correct
85 Correct 332 ms 50724 KB Output is correct
86 Correct 333 ms 51356 KB Output is correct
87 Correct 2 ms 6488 KB Output is correct
88 Correct 333 ms 50968 KB Output is correct
89 Correct 334 ms 51328 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 2 ms 6488 KB Output is correct
3 Correct 3 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6488 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 3 ms 6744 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 2 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 6488 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 2 ms 6488 KB Output is correct
23 Correct 2 ms 6488 KB Output is correct
24 Correct 2 ms 6488 KB Output is correct
25 Correct 3 ms 6488 KB Output is correct
26 Correct 8 ms 7644 KB Output is correct
27 Correct 9 ms 7988 KB Output is correct
28 Correct 8 ms 7764 KB Output is correct
29 Correct 8 ms 7256 KB Output is correct
30 Correct 8 ms 7996 KB Output is correct
31 Correct 8 ms 7476 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 6484 KB Output is correct
35 Correct 2 ms 6488 KB Output is correct
36 Correct 4 ms 6488 KB Output is correct
37 Correct 2 ms 6488 KB Output is correct
38 Correct 3 ms 6744 KB Output is correct
39 Correct 2 ms 6500 KB Output is correct
40 Correct 2 ms 6488 KB Output is correct
41 Correct 2 ms 6972 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 7956 KB Output is correct
46 Correct 8 ms 7784 KB Output is correct
47 Correct 8 ms 7524 KB Output is correct
48 Correct 9 ms 7588 KB Output is correct
49 Correct 8 ms 7636 KB Output is correct
50 Correct 9 ms 8012 KB Output is correct
51 Correct 2 ms 6488 KB Output is correct
52 Correct 19 ms 9736 KB Output is correct
53 Correct 20 ms 9768 KB Output is correct
54 Correct 21 ms 9712 KB Output is correct
55 Correct 20 ms 9308 KB Output is correct
56 Correct 20 ms 9356 KB Output is correct
57 Correct 20 ms 9768 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 6488 KB Output is correct
67 Correct 2 ms 6488 KB Output is correct
68 Correct 3 ms 6744 KB Output is correct
69 Correct 2 ms 6488 KB Output is correct
70 Correct 8 ms 7220 KB Output is correct
71 Correct 8 ms 7476 KB Output is correct
72 Correct 9 ms 7652 KB Output is correct
73 Correct 8 ms 7732 KB Output is correct
74 Correct 8 ms 7732 KB Output is correct
75 Correct 8 ms 8248 KB Output is correct
76 Correct 2 ms 6488 KB Output is correct
77 Correct 20 ms 9172 KB Output is correct
78 Correct 20 ms 9796 KB Output is correct
79 Correct 20 ms 9772 KB Output is correct
80 Correct 21 ms 9664 KB Output is correct
81 Correct 20 ms 9764 KB Output is correct
82 Correct 19 ms 9652 KB Output is correct
83 Correct 335 ms 50716 KB Output is correct
84 Correct 339 ms 50864 KB Output is correct
85 Correct 332 ms 50724 KB Output is correct
86 Correct 333 ms 51356 KB Output is correct
87 Correct 2 ms 6488 KB Output is correct
88 Correct 333 ms 50968 KB Output is correct
89 Correct 334 ms 51328 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 6700 KB Output is correct
97 Correct 2 ms 6488 KB Output is correct
98 Correct 2 ms 6488 KB Output is correct
99 Correct 2 ms 6488 KB Output is correct
100 Correct 3 ms 6744 KB Output is correct
101 Correct 8 ms 8244 KB Output is correct
102 Correct 9 ms 7756 KB Output is correct
103 Correct 9 ms 7656 KB Output is correct
104 Correct 8 ms 8244 KB Output is correct
105 Correct 8 ms 7472 KB Output is correct
106 Correct 9 ms 7724 KB Output is correct
107 Correct 3 ms 6488 KB Output is correct
108 Correct 20 ms 9808 KB Output is correct
109 Correct 20 ms 9284 KB Output is correct
110 Correct 21 ms 9372 KB Output is correct
111 Correct 20 ms 10208 KB Output is correct
112 Correct 20 ms 10052 KB Output is correct
113 Correct 23 ms 9856 KB Output is correct
114 Correct 333 ms 50584 KB Output is correct
115 Correct 332 ms 51060 KB Output is correct
116 Correct 336 ms 50832 KB Output is correct
117 Correct 333 ms 51076 KB Output is correct
118 Correct 2 ms 6488 KB Output is correct
119 Correct 336 ms 50848 KB Output is correct
120 Correct 334 ms 50868 KB Output is correct
121 Correct 1310 ms 173716 KB Output is correct
122 Correct 1319 ms 173660 KB Output is correct
123 Correct 1324 ms 173884 KB Output is correct
124 Correct 1329 ms 173632 KB Output is correct
125 Correct 1311 ms 173600 KB Output is correct
126 Correct 1323 ms 173672 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