Submission #920180

#TimeUsernameProblemLanguageResultExecution timeMemory
920180oblantisCarnival (CEOI14_carnival)C++17
100 / 100
7 ms556 KiB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define all(v) v.begin(), v.end() #define pb push_back #define ss second #define ff first #define vt vector using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair<int, int> pii; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int inf = 1e9; const int mod = 1e9+7; const int maxn = 1e6 + 1; int x; void ask(int l, int r){ cout << r - l + 1 << ' '; while(l <= r){ cout << l << ' '; l++; } cout << endl; cin >> x; } void solve() { int n; cin >> n; int l[n + 1]; l[0] = 0; vt<int> unq; unq.pb(0); for(int i = 1; i <= n; i++){ int xl = 0, xr = unq.size(); while(xl + 1 < xr){ int mid = (xl + xr) / 2; ask(unq[mid], i); for(int j = unq[mid]; j < i; j++){ if(l[j] < unq[mid])x--; } if(x)xr = mid; else xl = mid; } l[i] = unq[xl]; if(l[i] == 0){ unq.pb(i); } else unq.erase(unq.begin() + xl), unq.pb(i); } cout << 0 << ' '; for(int i = 1, cnt = 1; i <= n; i++){ if(l[i] == 0)l[i] = cnt++; else l[i] = l[l[i]]; cout << l[i] << ' '; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int times = 1; //cin >> times; for(int i = 1; i <= times; i++) { solve(); } return 0; }
#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...