Submission #710292

#TimeUsernameProblemLanguageResultExecution timeMemory
710292CDuongCarnival (CEOI14_carnival)C++17
100 / 100
13 ms328 KiB
/* #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt") */ #include <bits/stdc++.h> #define taskname "" #define all(x) x.begin(), x.end() #define ll long long #define ld long double #define pb push_back #define ff first #define ss second #define pii pair<int, int> #define vi vector<int> using namespace std; const int mxN = 2e5 + 5; const int mod = 1e9 + 7; const ll oo = 1e18; int n, ans[mxN]; vi diff; int ask(int l, int r, int idx) { cout << r - l + 2 << " "; for(int i = l; i <= r; ++i) cout << diff[i] << " "; cout << idx << endl; int ans; cin >> ans; return ans; } int binary_search(int idx) { int l = 0, r = diff.size() - 1, ans = diff.size() + 1; while(l <= r) { int mid = (l + r) >> 1; int tmp = ask(l, mid, idx); if(tmp == mid - l + 1) ans = mid + 1, r = mid - 1; else l = mid + 1; } if(ans == (int)diff.size() + 1) diff.pb(idx); return ans; } void solve() { cin >> n; diff.pb(1); ans[1] = 1; for(int i = 2; i <= n; ++i) ans[i] = binary_search(i); cout << 0 << " "; for(int i = 1; i <= n; ++i) cout << ans[i] << " "; cout << endl; } signed main() { #ifndef CDuongg if(fopen(taskname".inp", "r")) assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout)); #else freopen("bai3.inp", "r", stdin); freopen("bai3.out", "w", stdout); auto start = chrono::high_resolution_clock::now(); #endif ios_base::sync_with_stdio(false); cin.tie(nullptr); int t = 1; //cin >> t; while(t--) solve(); #ifdef CDuongg auto end = chrono::high_resolution_clock::now(); cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '='; cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...