# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1119291 | 2024-11-26T18:13:27 Z | thangdz2k7 | Library (JOI18_library) | C++17 | 439 ms | 592 KB |
// author : thembululquaUwU // 3.9.2024 #include <bits/stdc++.h> #include "library.h" #define pb push_back #define fi first #define se second #define endl '\n' using namespace std; using ll = long long; using ii = pair <int, int>; using vi = vector <int>; const int N = 1e5 + 5; const int mod = 1e9 + 7; void maxl(auto &a, auto b) {a = max(a, b);} void minl(auto &a, auto b) {a = min(a, b);} // grader //int n, p[N]; // //int Query(vector <int> qr){ // int ans = 0; // for (int i = 1; i <= n; ++ i) if (qr[p[i]] == 1 && (i == 1 || !qr[p[i - 1]])) ++ ans; // return ans; //} // //void Answer(vector <int> ans){ // for (int f : ans) cout << f << ' '; //} // end void Solve(int n){ vector <int> a(n); iota(a.begin(), a.end(), 0); auto del = [&](int x) -> void { a.erase(a.begin() + x); }; vector <int> qr(n, 1); int st = 0; for (int i = 1; i < n; ++ i){ qr[i] = 0; if (Query(qr) == 1){ st = i; break; } qr[i] = 1; } vector <int> ans = {st}; del(st); for (int loops = 1; loops < n; ++ loops){ int l = 0, r = a.size() - 1; //, g = 0; while (l < r){ int mid = l + r >> 1; qr.assign(n, 0); for (int i = 0; i <= mid; ++ i) qr[a[i]] = 1; int res = Query(qr); qr[ans.back()] = 1; if (res == Query(qr)) r = mid; else l = mid + 1; } ans.push_back(a[l]); del(l); } for (int &f : ans) f ++; Answer(ans); } //void solve(){ // cin >> n; // for (int i = 1; i <= n; ++ i) cin >> p[i], p[i] --; // Solve(n); //} // //int main(){ // if (fopen("Library.inp", "r")){ // freopen("Library.inp", "r", stdin); // freopen("Library.out", "w", stdout); // } // ios_base::sync_with_stdio(0); // cin.tie(0); cout.tie(0); // // int t = 1; // cin >> t; // while (t --) solve(); // return 0; //}
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 436 KB | # of queries: 2386 |
2 | Correct | 48 ms | 436 KB | # of queries: 2432 |
3 | Correct | 53 ms | 336 KB | # of queries: 2637 |
4 | Correct | 52 ms | 336 KB | # of queries: 2592 |
5 | Correct | 47 ms | 444 KB | # of queries: 2503 |
6 | Correct | 55 ms | 436 KB | # of queries: 2552 |
7 | Correct | 57 ms | 592 KB | # of queries: 2567 |
8 | Correct | 49 ms | 436 KB | # of queries: 2401 |
9 | Correct | 57 ms | 440 KB | # of queries: 2511 |
10 | Correct | 32 ms | 588 KB | # of queries: 1477 |
11 | Correct | 1 ms | 336 KB | # of queries: 0 |
12 | Correct | 1 ms | 336 KB | # of queries: 1 |
13 | Correct | 1 ms | 336 KB | # of queries: 3 |
14 | Correct | 1 ms | 336 KB | # of queries: 9 |
15 | Correct | 3 ms | 336 KB | # of queries: 79 |
16 | Correct | 4 ms | 336 KB | # of queries: 186 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 436 KB | # of queries: 2386 |
2 | Correct | 48 ms | 436 KB | # of queries: 2432 |
3 | Correct | 53 ms | 336 KB | # of queries: 2637 |
4 | Correct | 52 ms | 336 KB | # of queries: 2592 |
5 | Correct | 47 ms | 444 KB | # of queries: 2503 |
6 | Correct | 55 ms | 436 KB | # of queries: 2552 |
7 | Correct | 57 ms | 592 KB | # of queries: 2567 |
8 | Correct | 49 ms | 436 KB | # of queries: 2401 |
9 | Correct | 57 ms | 440 KB | # of queries: 2511 |
10 | Correct | 32 ms | 588 KB | # of queries: 1477 |
11 | Correct | 1 ms | 336 KB | # of queries: 0 |
12 | Correct | 1 ms | 336 KB | # of queries: 1 |
13 | Correct | 1 ms | 336 KB | # of queries: 3 |
14 | Correct | 1 ms | 336 KB | # of queries: 9 |
15 | Correct | 3 ms | 336 KB | # of queries: 79 |
16 | Correct | 4 ms | 336 KB | # of queries: 186 |
17 | Correct | 439 ms | 444 KB | # of queries: 18007 |
18 | Correct | 415 ms | 444 KB | # of queries: 17230 |
19 | Correct | 405 ms | 440 KB | # of queries: 17450 |
20 | Correct | 371 ms | 444 KB | # of queries: 16276 |
21 | Correct | 365 ms | 436 KB | # of queries: 15361 |
22 | Correct | 423 ms | 436 KB | # of queries: 17616 |
23 | Correct | 438 ms | 440 KB | # of queries: 17169 |
24 | Correct | 178 ms | 436 KB | # of queries: 7884 |
25 | Correct | 392 ms | 440 KB | # of queries: 17117 |
26 | Correct | 391 ms | 436 KB | # of queries: 15988 |
27 | Correct | 172 ms | 436 KB | # of queries: 7993 |
28 | Correct | 381 ms | 440 KB | # of queries: 16955 |
29 | Correct | 393 ms | 440 KB | # of queries: 16936 |
30 | Correct | 380 ms | 436 KB | # of queries: 16955 |