Submission #705284

#TimeUsernameProblemLanguageResultExecution timeMemory
705284lukameladzeCarnival (CEOI14_carnival)C++14
100 / 100
10 ms340 KiB
# include <bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define pii pair <int,int> const int N = 3e5 + 5; int le,ri,mid,pas[N],idx[N],a[N],pre,n; vector <int> v,v1; int ask(vector <int> vv) { cout<<vv.size()<<" "; for (int i = 0; i < vv.size(); i++) { cout<<vv[i]<<" "; } cout<<endl; int x; cin>>x; return x; } void go(vector <int> v) { int x = v.back(); int ans = 0; le = 0; ri = (int)v.size() - 2; while (le <= ri) { int mid = (le + ri) / 2; vector <int> v1; for (int j = 0; j <= mid; j++) v1.pb(v[j]); v1.pb(x); if (ask(v1) == v1.size()) { le = mid + 1; } else {ans = mid; ri = mid - 1;} } pas[x] = pas[v[ans]]; //cout<<x<<" ---> "<<pas[x]<<endl; } main() { std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>n; v.pb(1); pre = 1; idx[pre] = 1; pas[1] = 1; for (int i = 2; i <= n; i++) { v.pb(i); if (ask(v) == pre) { go(v); v.pop_back(); } else pre++, idx[pre] = i, pas[i] = pre; } cout<<0<<" "; for (int i = 1; i <= n; i++) { cout<<pas[i]<<" "; } }

Compilation message (stderr)

carnival.cpp: In function 'int ask(std::vector<int>)':
carnival.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i = 0; i < vv.size(); i++) {
      |                     ~~^~~~~~~~~~~
carnival.cpp: In function 'void go(std::vector<int>)':
carnival.cpp:29:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         if (ask(v1) == v1.size()) {
      |             ~~~~~~~~^~~~~~~~~~~~
carnival.cpp: At global scope:
carnival.cpp:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 | main() {
      | ^~~~
#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...