Submission #740344

#TimeUsernameProblemLanguageResultExecution timeMemory
740344UnforgettableplCarnival (CEOI14_carnival)C++17
100 / 100
9 ms316 KiB
/* ID: samikgo1 TASK: LANG: C++ */ #include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; typedef pair<ll,ll> pll; #define all(x) x.begin(),x.end() #define allr(x) x.rbegin(),x.rend() #define f first #define s second //#define x first //#define y second const int INF = INT32_MAX; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); // freopen("haybales.in","r",stdin); // freopen("haybales.out","w",stdout); int n; cin >> n; vector<int> unique = {1}; vector<int> ans(n+1); ans[1] = 1; for (int i = 2; i <= n; i++) { cout << unique.size()+1; for(int&j:unique)cout << ' ' << j; cout << ' ' << i << endl; int a; cin >> a; if(a==unique.size()+1){ unique.emplace_back(i); ans[i] = unique.size(); } else { // Now binary search int l = 0; int r = unique.size()-1; while(l<r){ int mid = (l+r)>>1; cout << mid-l+2; for (int j = l; j <= mid; j++) { cout << ' ' << unique[j]; } cout << ' ' << i << endl; cin >> a; if(a==mid-l+2){l=mid+1;} else{r = mid;} } ans[i] = ans[unique[l]]; } } cout << '0'; for(int i=1;i<=n;i++)cout<<' '<<ans[i]; cout << endl; }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:34:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if(a==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...