Submission #422483

#TimeUsernameProblemLanguageResultExecution timeMemory
422483snasibov05Carnival (CEOI14_carnival)C++14
100 / 100
17 ms328 KiB
#include <iostream> #include <vector> using namespace std; #define pb push_back int ask(vector<int> v){ cout << v.size() << " "; for (auto x : v) cout << x << " "; cout << endl; int res; cin >> res; return res; } void answer(vector<int> ans){ int n = ans.size() - 1; cout << "0 "; for (int i = 1; i <= n; ++i){ cout << ans[i] << " "; } cout << "\n"; } int main() { int n; cin >> n; vector<int> ans(n+1); ans[1] = 1; vector<int> unique; unique.pb(1); for (int i = 2; i <= n; ++i){ vector<int> v; for (auto x : unique) v.pb(x); v.pb(i); int k = ask(v); if (k == unique.size() + 1){ ans[i] = ans[unique.back()] + 1; unique.pb(i); continue; } int l = 0, r = unique.size() - 1; while (l < r){ int m = (l + r) / 2; v.clear(); for (int j = l; j <= m; ++j) { v.pb(unique[j]); } v.pb(i); k = ask(v); if (k == m - l + 1) r = m; else l = m+1; } ans[i] = ans[unique[l]]; } answer(ans); return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:36:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         if (k == unique.size() + 1){
      |             ~~^~~~~~~~~~~~~~~~~~~~
#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...