Submission #396257

#TimeUsernameProblemLanguageResultExecution timeMemory
396257VictorCarnival (CEOI14_carnival)C++17
100 / 100
18 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define per(i, a, b) for (int i = b - 1; i >= (a); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) x.size() #define pb push_back #define umap unordered_map #define uset unordered_set typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef long long ll; const int INF = 1000000007; vi ans; int cur; int binsearch(vi party) { if (sz(party) == 1) return ans[party[0]]; vi next; rep(i, 0, sz(party) >> 1) next.push_back(party[i]); next.pb(cur); cout << sz(next); trav(person, next) cout << ' ' << person + 1; cout << endl; int c1; cin >> c1; next.pop_back(); cout << sz(next); trav(person, next) cout << ' ' << person + 1; cout << endl; int c2; cin >> c2; if (c2 < c1) { next.clear(); rep(i, sz(party) >> 1, sz(party)) next.push_back(party[i]); } return binsearch(next); } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int n; cin >> n; ans.resize(n); vi party; rep(i, 0, n) { int costumes; party.pb(i); cout<<sz(party); trav(person,party)cout<<' '<<person+1; cout<<endl; cin>>costumes; if (costumes==sz(party)) { ans[i] = sz(party); continue; } party.pop_back(); cur = i; ans[i] = binsearch(party); } cout<<0; rep(i,0,n)cout<<' '<<ans[i]; cout<<endl; return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int binsearch(vi)':
carnival.cpp:5:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i, a, b) for (int i = a; i < (b); ++i)
      |                                        ^
carnival.cpp:33:5: note: in expansion of macro 'rep'
   33 |     rep(i, 0, sz(party) >> 1) next.push_back(party[i]);
      |     ^~~
carnival.cpp:5:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i, a, b) for (int i = a; i < (b); ++i)
      |                                        ^
carnival.cpp:53:9: note: in expansion of macro 'rep'
   53 |         rep(i, sz(party) >> 1, sz(party)) next.push_back(party[i]);
      |         ^~~
carnival.cpp: In function 'int main()':
carnival.cpp:76:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |         if (costumes==sz(party)) {
      |                     ^
#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...