# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
441316 | 2021-07-04T23:44:06 Z | Agnimandur | Library (JOI18_library) | C++17 | 13 ms | 200 KB |
#include <bits/stdc++.h> #include "library.h" #define ll long long #define sz(x) ((int) (x).size()) #define all(x) (x).begin(), (x).end() #define vi vector<int> #define vl vector<long long> #define pii pair<int, int> #define pll pair<ll,ll> #define add push_back using namespace std; vi build(vi &alive, int i, int j) { int N = sz(alive); vi ret; ret.assign(N,0); int ind = 0; for (int i = 0; i < N; i++) { if (alive[i]==1 && (i <= ind && ind <= j)) { ret[i] = 1; ind++; } } return ret; } void Solve(int N) { int end = -1; for (int i = 0; i < N; i++) { vi nums; nums.assign(N,1); nums[i] = 0; int A = Query(nums); if (A==1) { end = i; break; } } vi ans; ans.add(end); vi alive; alive.assign(N,1); alive[end] = 0; for (int s = N-1; s >= 1; s--) { int lo = 0; int hi = s-1; int last = ans[sz(ans)-1]; while (lo < hi) { int m = (lo+hi)/2; vi M = build(alive,lo,m); int x = 1; if (lo<m) x = Query(M); M[last] = 1; int y = Query(M); if (y==x) { hi = m; } else { lo = m+1; } } ans.add(lo); alive[lo] = 0; } for (int i = 0; i < N; i++) ans[i]++; Answer(ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 200 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 200 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |