Submission #707332

# Submission time Handle Problem Language Result Execution time Memory
707332 2023-03-08T19:26:53 Z Danilo21 Library (JOI18_library) C++14
100 / 100
570 ms 472 KB
#include <bits/stdc++.h>
#include "library.h"

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "Yes" << en
#define no cout << "No" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))

using namespace std;

const ll LINF = 1e18;
const int mxN = 1e3+10, INF = 2e9;
ll n;
vector<int> g[mxN], ans;

void dfs(int s, int p = -1){

    ans.pb(s+1);
    for (int u : g[s])
        if (u^p) dfs(u, s);
}

int Get(int i, int l, int r){

    vector<int> M(n, 0);
    for (int i = l; i <= r; i++)
        M[i] = 1;
    int x = Query(M);
    M[i] = 1;
    return 1 - (Query(M) - x);
}

void BS(int i, int l, int r, int x){

    if (l == r){
        g[i].pb(l);
        g[l].pb(i);
        return;
    }
    int k = (l + r)>>1;
    int y = Get(i, l, k);
    if (y) BS(i, l, k, y);
    if (x-y) BS(i, k+1, r, x-y);
}

void Solve(int N)
{
    cerr << 1 << endl;
	n = N;
	for (int i = 1; i < n; i++){
        int x = Get(i, 0, i-1);
        if (x) BS(i, 0, i-1, x);
	}
    int s;
    for (s = 0; g[s].size() > 1; s++){}
    dfs(s);
    Answer(ans);
}

# Verdict Execution time Memory Grader output
1 Correct 49 ms 332 KB # of queries: 2730
2 Correct 48 ms 308 KB # of queries: 2798
3 Correct 38 ms 316 KB # of queries: 2864
4 Correct 41 ms 208 KB # of queries: 2898
5 Correct 36 ms 316 KB # of queries: 2884
6 Correct 41 ms 328 KB # of queries: 2850
7 Correct 43 ms 208 KB # of queries: 2940
8 Correct 42 ms 208 KB # of queries: 2796
9 Correct 41 ms 328 KB # of queries: 2930
10 Correct 19 ms 208 KB # of queries: 1712
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 2
13 Correct 1 ms 208 KB # of queries: 6
14 Correct 1 ms 208 KB # of queries: 12
15 Correct 2 ms 208 KB # of queries: 98
16 Correct 4 ms 208 KB # of queries: 230
# Verdict Execution time Memory Grader output
1 Correct 49 ms 332 KB # of queries: 2730
2 Correct 48 ms 308 KB # of queries: 2798
3 Correct 38 ms 316 KB # of queries: 2864
4 Correct 41 ms 208 KB # of queries: 2898
5 Correct 36 ms 316 KB # of queries: 2884
6 Correct 41 ms 328 KB # of queries: 2850
7 Correct 43 ms 208 KB # of queries: 2940
8 Correct 42 ms 208 KB # of queries: 2796
9 Correct 41 ms 328 KB # of queries: 2930
10 Correct 19 ms 208 KB # of queries: 1712
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 2
13 Correct 1 ms 208 KB # of queries: 6
14 Correct 1 ms 208 KB # of queries: 12
15 Correct 2 ms 208 KB # of queries: 98
16 Correct 4 ms 208 KB # of queries: 230
17 Correct 407 ms 340 KB # of queries: 19364
18 Correct 458 ms 340 KB # of queries: 19016
19 Correct 570 ms 332 KB # of queries: 19160
20 Correct 419 ms 336 KB # of queries: 17832
21 Correct 396 ms 332 KB # of queries: 16854
22 Correct 517 ms 444 KB # of queries: 19274
23 Correct 474 ms 464 KB # of queries: 19252
24 Correct 138 ms 328 KB # of queries: 8846
25 Correct 439 ms 348 KB # of queries: 18830
26 Correct 391 ms 344 KB # of queries: 17506
27 Correct 156 ms 336 KB # of queries: 8832
28 Correct 434 ms 348 KB # of queries: 17954
29 Correct 408 ms 472 KB # of queries: 17934
30 Correct 438 ms 444 KB # of queries: 17954