Submission #575087

#TimeUsernameProblemLanguageResultExecution timeMemory
575087MadokaMagicaFanLibrary (JOI18_library)C++14
0 / 100
5 ms208 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; const ll inf = 1e9; const int md1 = 1e9+7; const int md2 = 998244353; #define sz(v) ((int)v.size()) #define pb push_back #define pry cout << "YES\n" #define prn cout << "NO\n" #define endl '\n' #define fst first #define scn second /* #define ONPC */ const int N = 1e3; bitset<N+1> c; vector<int> m; int n; int Query(const vector<int> &M); void Answer(const vector<int> &res); bool comp(int l, int r, int x) { for (int i = 0; i < n; ++i) { m[i] = 0; } int cnt = 0; for (int i = 1; i < n+1; ++i) { if (c[i]) continue; if (cnt >= l && cnt < r) m[i-1] = 1; ++cnt; } int a1 = Query(m); m[x] = 1; int a2 = Query(m); return (a1 == a2); } int arrsize() { int s = 0; for (int i = 1; i < n+1; ++i) { if (!c[i]) ++s; } return s; } int getval(int l) { for (int i = 1; i < n+1; ++i) { if (c[i]) continue; --l; if (!l) return i; } return -1; } int bs(int x) { int l = 0; int r = arrsize(); if (r == 1) return getval(1); if (r == 0) return 0; int mid; while (l < r) { mid = (l+r)>>1; if (comp(l,mid,x)) r = mid; else l = mid+1; } return getval(l); } void Solve(int _n) { n = _n; m.assign(n,1); int val = -1; for (int i = 1; i < n+1; ++i) { m[i-1] = 0; if (Query(m) == 1) { val = i; break; } m[i-1] = 1; } c[val] = 1; vector<int> ans; ans.pb(val); while (1) { val = bs(val); if (!val) break; c[val] = 1; ans.pb(val); } Answer(ans); return; } #ifdef ONPC void solve() { } int32_t main(int argc, char **argv) { if (argc >= 2) { freopen(argv[1], "r", stdin); } else ios_base::sync_with_stdio(0);cin.tie(0); int t = 1; /* cin >> t; */ while(t--) solve(); } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...