답안 #893297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
893297 2023-12-26T21:33:34 Z box 도서관 (JOI18_library) C++17
0 / 100
29 ms 684 KB
#include <bits/stdc++.h>
using namespace std;

#define ar array
#define sz(v) int(std::size(v))
using i64 = long long;
using pii = pair<int, int>;

#include "library.h"

void Solve(int n) {
    vector<pii> edges;
    auto expected = [&](vector<int> v) {
        int save = 0;
        for (auto [i, j] : edges) save += v[i] && v[j];
        return count(begin(v), end(v), 1) - save;
    };
    for (int rep = 0; rep < n - 1; rep++) {
        int low = 0, hi = n - 1;
        while (low < hi) {
            int mid = (low + hi) / 2;
            vector<int> v(n);
            fill(begin(v), begin(v) + mid + 1, 1);
            Query(v) < expected(v) ? hi = mid : low = mid + 1;
        }
        int x = low;
        low = 0, hi = x - 1;
        while (low < hi) {
            int mid = (low + hi) / 2 + 1;
            vector<int> v(n);
            fill(begin(v) + mid, begin(v) + x + 1, 1);
            Query(v) < expected(v) ? low = mid : hi = mid - 1;
        }
        edges.push_back({low, x});
    }
    vector<vector<int>> adj(n);
    for (auto [i, j] : edges) adj[i].push_back(j), adj[j].push_back(i);
    int src = -1;
    for (int i = 0; i < n; i++) if (sz(adj[i]) == 1) src = i;
    vector<int> ans{{src, adj[src][0]}};
    while (sz(ans) < n) ans.push_back(adj[end(ans)[-1]][0] ^ adj[end(ans)[-1]][1] ^ end(ans)[-2]);
    for (int &x : ans) x++;
    Answer(ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 684 KB # of queries: 2793
2 Correct 22 ms 432 KB # of queries: 2772
3 Correct 26 ms 684 KB # of queries: 2917
4 Correct 27 ms 436 KB # of queries: 2923
5 Correct 29 ms 672 KB # of queries: 2909
6 Correct 26 ms 436 KB # of queries: 2915
7 Correct 22 ms 440 KB # of queries: 2929
8 Correct 20 ms 440 KB # of queries: 2799
9 Correct 24 ms 436 KB # of queries: 2922
10 Correct 17 ms 432 KB # of queries: 1707
11 Runtime error 1 ms 344 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 684 KB # of queries: 2793
2 Correct 22 ms 432 KB # of queries: 2772
3 Correct 26 ms 684 KB # of queries: 2917
4 Correct 27 ms 436 KB # of queries: 2923
5 Correct 29 ms 672 KB # of queries: 2909
6 Correct 26 ms 436 KB # of queries: 2915
7 Correct 22 ms 440 KB # of queries: 2929
8 Correct 20 ms 440 KB # of queries: 2799
9 Correct 24 ms 436 KB # of queries: 2922
10 Correct 17 ms 432 KB # of queries: 1707
11 Runtime error 1 ms 344 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -