Submission #1008497

#TimeUsernameProblemLanguageResultExecution timeMemory
1008497VMaksimoski008Carnival (CEOI14_carnival)C++17
100 / 100
5 ms596 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() //#define int long long using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e5 + 5; signed main() { int n; cin >> n; vector<int> diff; vector<int> v(n+1); v[1] = 1; diff.push_back(1); auto query = [&](vector<int> &vec) { cout << vec.size(); for(int &el : vec) cout << " " << el; cout << endl; int ans; cin >> ans; return ans; }; int id = 2; for(int i=2; i<=n; i++) { int x = diff.size(); diff.push_back(i); if(query(diff) == diff.size()) { v[i] = id++; continue; } diff.pop_back(); int l=0, r=diff.size()-1, p=r; while(l <= r) { int mid = (l + r) / 2; vector<int> vec; for(int j=0; j<=mid; j++) vec.push_back(diff[j]); vec.push_back(i); if(query(vec) == vec.size() - 1) p = mid, r = mid - 1; else l = mid + 1; } v[i] = v[diff[p]]; } cout << 0; for(int i=1; i<=n; i++) cout << " " << v[i]; cout << endl; return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:40:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if(query(diff) == diff.size()) {
      |            ~~~~~~~~~~~~^~~~~~~~~~~~~~
carnival.cpp:53:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |             if(query(vec) == vec.size() - 1) p = mid, r = mid - 1;
      |                ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
carnival.cpp:38:13: warning: unused variable 'x' [-Wunused-variable]
   38 |         int x = diff.size();
      |             ^
#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...