Submission #752679

#TimeUsernameProblemLanguageResultExecution timeMemory
752679DeathIsAweCarnival (CEOI14_carnival)C++17
100 / 100
8 ms208 KiB
#include <bits/stdc++.h> using namespace std; int binsearch(int c,vector<int>& uppl) { int org=c; int a=0,b=c/2,output; while (a!=b) { cout << c-b+1 << ' '; for (int i=b;i<c;i++) { cout << uppl[i] << ' '; } cout << uppl[org] << '\n'; cin >> output; if (output<c-b+1) { a=b; b=(c-a)/2+a; } else { c=b; b=(c-a)/2+a; } } return b; } int main() { vector<vector<int>> samekind(151); int n,output; cin >> n; vector<int> ans(n+1); vector<int> uppl; for (int i=0;i<n;i++) { uppl.push_back(i+1); } int canceler=0,searchres; for (int i=0;i<n;i++) { cout << i+1-canceler << ' '; for (int j=0;j<i-canceler+1;j++) { cout << uppl[j] << ' '; } cout << '\n'; cin >> output; if (output<i+1-canceler) { searchres=binsearch(i-canceler,uppl); samekind[uppl[searchres]].push_back(uppl[i-canceler]); uppl.erase(uppl.begin()+i-canceler); canceler+=1; } } for (int i=0;i<uppl.size();i++) { ans[uppl[i]]=i+1; for (auto &j: samekind[uppl[i]]) { ans[j]=i+1; } } cout << 0 << ' '; for (int i=1;i<n+1;i++) { cout << ans[i] << ' '; } return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for (int i=0;i<uppl.size();i++) {
      |                  ~^~~~~~~~~~~~
#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...