답안 #714430

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
714430 2023-03-24T11:43:33 Z vjudge1 Art Collections (BOI22_art) C++17
100 / 100
1629 ms 63644 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "art.h"

/* DEFINES */
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define ld long double
#define npos ULLONG_MAX
#define INF LLONG_MAX
#define vv(a) vector<a>
#define pp(a, b) pair<a, b>
#define pq(a) priority_queue<a>
#define qq(a) queue<a>
#define ss(a) set<a>
#define mm(a, b) map<a, b>
#define ump(a, b) unordered_map<a, b>
#define sync                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define elif else if
#define endl "\n"
#define allc(a) begin(a), end(a)
#define all(a) a, a + sizeof(a) / sizeof(a[0])
#define pb push_back
#define logi(a) __lg(a)
#define sqrt(a) sqrtl(a)
#define mpr make_pair
#define ins insert
using namespace std;
using namespace __gnu_pbds;
using namespace __cxx11;
typedef char chr;
typedef basic_string<chr> str;
template <typename T, typename key = less<T>>
using ordered_set = tree<T, null_type, key, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vv(int) R, ans;
mm(vv(int), ll) mp;
void solve(ll l, ll r)
{
    if (l >= r)
        return;
    if (l + 1 == r)
    {
        ll val;
        if (!mp.count(ans))
            mp[ans] = publish(ans);
        val = mp[ans];
        swap(ans[l], ans[l + 1]);
        if (!mp.count(ans))
            mp[ans] = publish(ans);
        if (mp[ans] >= val)
            swap(ans[l], ans[l + 1]);
        return;
    }
    ll mid = (l + r) >> 1, val;
    solve(l, mid);
    solve(mid + 1, r);
    if (!mp.count(ans))
        mp[ans] = publish(ans);
    val = mp[ans];

}
void solve(int n)
{
    for (ll i = 0; i < n; i++)
        R.pb(i + 1);
    ans.resize(n, 0);
    for (ll i = 1; i < n; i++)
    {
        if (!mp.count(R))
            mp[R] = publish(R);
        ll val = mp[R];
        R.pb(R.front());
        R.erase(R.begin());
        if (!mp.count(R))
            mp[R] = publish(R);
        ll x = mp[R] - val;
        ans[n - ((n - 1 + x) >> 1) - 1] = i;
    }
    ll ind[n + 1];
    memset(ind, -1, sizeof(ind));
    for (ll i = 0; i < n; i++)
        ind[ans[i]] = i;
    ll idx;
    for (idx = 1; idx <= n; idx++)
        if (ind[idx] == -1)
            break;
    ans[ind[0]] = idx;
    answer(ans);
}
/*

*/
// int main()
// {
//     sync
//         // precomp();
//         ll t = 1;
//     cin >> t;
//     for (ll i = 1; i <= t; i++)
//         // cout << "Case " << i << ": ",
//         solve();
//     cerr << "\nTime elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
// }

Compilation message

art.cpp: In function 'void solve(long long int, long long int)':
art.cpp:64:28: warning: variable 'val' set but not used [-Wunused-but-set-variable]
   64 |     ll mid = (l + r) >> 1, val;
      |                            ^~~
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 1 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 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 1 ms 208 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 8 ms 488 KB Output is correct
27 Correct 9 ms 536 KB Output is correct
28 Correct 8 ms 464 KB Output is correct
29 Correct 9 ms 516 KB Output is correct
30 Correct 9 ms 540 KB Output is correct
31 Correct 9 ms 464 KB Output is correct
32 Correct 1 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 0 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 1 ms 208 KB Output is correct
39 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 1 ms 208 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 8 ms 488 KB Output is correct
27 Correct 9 ms 536 KB Output is correct
28 Correct 8 ms 464 KB Output is correct
29 Correct 9 ms 516 KB Output is correct
30 Correct 9 ms 540 KB Output is correct
31 Correct 9 ms 464 KB Output is correct
32 Correct 1 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 0 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 1 ms 208 KB Output is correct
39 Correct 1 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 1 ms 208 KB Output is correct
42 Correct 1 ms 208 KB Output is correct
43 Correct 1 ms 208 KB Output is correct
44 Correct 2 ms 208 KB Output is correct
45 Correct 13 ms 592 KB Output is correct
46 Correct 8 ms 564 KB Output is correct
47 Correct 8 ms 464 KB Output is correct
48 Correct 8 ms 464 KB Output is correct
49 Correct 8 ms 476 KB Output is correct
50 Correct 8 ms 504 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Correct 30 ms 1092 KB Output is correct
53 Correct 30 ms 1024 KB Output is correct
54 Correct 22 ms 1104 KB Output is correct
55 Correct 30 ms 1040 KB Output is correct
56 Correct 21 ms 1008 KB Output is correct
57 Correct 22 ms 1040 KB Output is correct
58 Correct 1 ms 208 KB Output is correct
59 Correct 1 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 1 ms 208 KB Output is correct
64 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 1 ms 208 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 8 ms 488 KB Output is correct
27 Correct 9 ms 536 KB Output is correct
28 Correct 8 ms 464 KB Output is correct
29 Correct 9 ms 516 KB Output is correct
30 Correct 9 ms 540 KB Output is correct
31 Correct 9 ms 464 KB Output is correct
32 Correct 1 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 0 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 1 ms 208 KB Output is correct
39 Correct 1 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 1 ms 208 KB Output is correct
42 Correct 1 ms 208 KB Output is correct
43 Correct 1 ms 208 KB Output is correct
44 Correct 2 ms 208 KB Output is correct
45 Correct 13 ms 592 KB Output is correct
46 Correct 8 ms 564 KB Output is correct
47 Correct 8 ms 464 KB Output is correct
48 Correct 8 ms 464 KB Output is correct
49 Correct 8 ms 476 KB Output is correct
50 Correct 8 ms 504 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Correct 30 ms 1092 KB Output is correct
53 Correct 30 ms 1024 KB Output is correct
54 Correct 22 ms 1104 KB Output is correct
55 Correct 30 ms 1040 KB Output is correct
56 Correct 21 ms 1008 KB Output is correct
57 Correct 22 ms 1040 KB Output is correct
58 Correct 1 ms 208 KB Output is correct
59 Correct 1 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 1 ms 208 KB Output is correct
64 Correct 1 ms 208 KB Output is correct
65 Correct 1 ms 256 KB Output is correct
66 Correct 1 ms 208 KB Output is correct
67 Correct 1 ms 208 KB Output is correct
68 Correct 1 ms 208 KB Output is correct
69 Correct 1 ms 208 KB Output is correct
70 Correct 8 ms 548 KB Output is correct
71 Correct 11 ms 484 KB Output is correct
72 Correct 8 ms 440 KB Output is correct
73 Correct 8 ms 464 KB Output is correct
74 Correct 7 ms 468 KB Output is correct
75 Correct 10 ms 508 KB Output is correct
76 Correct 0 ms 208 KB Output is correct
77 Correct 20 ms 1020 KB Output is correct
78 Correct 20 ms 1184 KB Output is correct
79 Correct 22 ms 1012 KB Output is correct
80 Correct 21 ms 1096 KB Output is correct
81 Correct 23 ms 1048 KB Output is correct
82 Correct 25 ms 1064 KB Output is correct
83 Correct 391 ms 16132 KB Output is correct
84 Correct 389 ms 16124 KB Output is correct
85 Correct 380 ms 16080 KB Output is correct
86 Correct 412 ms 16096 KB Output is correct
87 Correct 0 ms 208 KB Output is correct
88 Correct 393 ms 16292 KB Output is correct
89 Correct 393 ms 16256 KB Output is correct
90 Correct 1 ms 208 KB Output is correct
91 Correct 0 ms 208 KB Output is correct
92 Correct 1 ms 208 KB Output is correct
93 Correct 1 ms 208 KB Output is correct
94 Correct 1 ms 208 KB Output is correct
95 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 1 ms 208 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 8 ms 488 KB Output is correct
27 Correct 9 ms 536 KB Output is correct
28 Correct 8 ms 464 KB Output is correct
29 Correct 9 ms 516 KB Output is correct
30 Correct 9 ms 540 KB Output is correct
31 Correct 9 ms 464 KB Output is correct
32 Correct 1 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 0 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 1 ms 208 KB Output is correct
39 Correct 1 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 1 ms 208 KB Output is correct
42 Correct 1 ms 208 KB Output is correct
43 Correct 1 ms 208 KB Output is correct
44 Correct 2 ms 208 KB Output is correct
45 Correct 13 ms 592 KB Output is correct
46 Correct 8 ms 564 KB Output is correct
47 Correct 8 ms 464 KB Output is correct
48 Correct 8 ms 464 KB Output is correct
49 Correct 8 ms 476 KB Output is correct
50 Correct 8 ms 504 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Correct 30 ms 1092 KB Output is correct
53 Correct 30 ms 1024 KB Output is correct
54 Correct 22 ms 1104 KB Output is correct
55 Correct 30 ms 1040 KB Output is correct
56 Correct 21 ms 1008 KB Output is correct
57 Correct 22 ms 1040 KB Output is correct
58 Correct 1 ms 208 KB Output is correct
59 Correct 1 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 1 ms 208 KB Output is correct
64 Correct 1 ms 208 KB Output is correct
65 Correct 1 ms 256 KB Output is correct
66 Correct 1 ms 208 KB Output is correct
67 Correct 1 ms 208 KB Output is correct
68 Correct 1 ms 208 KB Output is correct
69 Correct 1 ms 208 KB Output is correct
70 Correct 8 ms 548 KB Output is correct
71 Correct 11 ms 484 KB Output is correct
72 Correct 8 ms 440 KB Output is correct
73 Correct 8 ms 464 KB Output is correct
74 Correct 7 ms 468 KB Output is correct
75 Correct 10 ms 508 KB Output is correct
76 Correct 0 ms 208 KB Output is correct
77 Correct 20 ms 1020 KB Output is correct
78 Correct 20 ms 1184 KB Output is correct
79 Correct 22 ms 1012 KB Output is correct
80 Correct 21 ms 1096 KB Output is correct
81 Correct 23 ms 1048 KB Output is correct
82 Correct 25 ms 1064 KB Output is correct
83 Correct 391 ms 16132 KB Output is correct
84 Correct 389 ms 16124 KB Output is correct
85 Correct 380 ms 16080 KB Output is correct
86 Correct 412 ms 16096 KB Output is correct
87 Correct 0 ms 208 KB Output is correct
88 Correct 393 ms 16292 KB Output is correct
89 Correct 393 ms 16256 KB Output is correct
90 Correct 1 ms 208 KB Output is correct
91 Correct 0 ms 208 KB Output is correct
92 Correct 1 ms 208 KB Output is correct
93 Correct 1 ms 208 KB Output is correct
94 Correct 1 ms 208 KB Output is correct
95 Correct 1 ms 208 KB Output is correct
96 Correct 1 ms 208 KB Output is correct
97 Correct 1 ms 208 KB Output is correct
98 Correct 1 ms 208 KB Output is correct
99 Correct 1 ms 208 KB Output is correct
100 Correct 1 ms 208 KB Output is correct
101 Correct 12 ms 540 KB Output is correct
102 Correct 8 ms 500 KB Output is correct
103 Correct 8 ms 468 KB Output is correct
104 Correct 7 ms 540 KB Output is correct
105 Correct 7 ms 456 KB Output is correct
106 Correct 8 ms 616 KB Output is correct
107 Correct 0 ms 208 KB Output is correct
108 Correct 20 ms 1008 KB Output is correct
109 Correct 20 ms 1064 KB Output is correct
110 Correct 21 ms 1052 KB Output is correct
111 Correct 21 ms 1084 KB Output is correct
112 Correct 21 ms 1080 KB Output is correct
113 Correct 20 ms 1096 KB Output is correct
114 Correct 430 ms 16332 KB Output is correct
115 Correct 376 ms 16168 KB Output is correct
116 Correct 361 ms 16236 KB Output is correct
117 Correct 481 ms 16080 KB Output is correct
118 Correct 0 ms 208 KB Output is correct
119 Correct 393 ms 16240 KB Output is correct
120 Correct 401 ms 16368 KB Output is correct
121 Correct 1504 ms 63468 KB Output is correct
122 Correct 1560 ms 63404 KB Output is correct
123 Correct 1582 ms 63456 KB Output is correct
124 Correct 1629 ms 63464 KB Output is correct
125 Correct 1510 ms 63476 KB Output is correct
126 Correct 1577 ms 63644 KB Output is correct
127 Correct 1 ms 208 KB Output is correct
128 Correct 0 ms 208 KB Output is correct
129 Correct 0 ms 208 KB Output is correct
130 Correct 1 ms 208 KB Output is correct
131 Correct 1 ms 308 KB Output is correct
132 Correct 1 ms 208 KB Output is correct