Submission #131847

#TimeUsernameProblemLanguageResultExecution timeMemory
131847shafinalamCarnival (CEOI14_carnival)C++14
0 / 100
9 ms376 KiB
#include <bits/stdc++.h> using namespace std; int ans[1000]; int query(vector<int>v) { int sz = v.size(); cout << sz; for(int i : v) cout << ' ' << i; cout << endl; int x; cin >> x; return x; } int main() { int n; cin >> n; vector<int>arr; arr.push_back(1); for(int i = 2; i <= n; i++) { vector<int>tmp = arr; tmp.push_back(i); if(query(tmp)==tmp.size()) arr = tmp; } for(int i = 0; i < arr.size(); i++) ans[arr[i]] = i+1; for(int i = 1; i <= n; i++) { if(ans[i]) continue; int lo = 0, hi = arr.size()-1, indx; while(lo<=hi) { int mid = (lo+hi)>>1; vector<int>tmp; tmp.push_back(i); for(int r = 0; r < mid; r++) tmp.push_back(arr[r]); if(query(tmp)==mid) { indx = mid-1; hi = mid-1; } else lo = mid+1; } ans[i] = ans[arr[indx]]; } cout << 0; for(int i = 1; i <= n; i++) cout << " " << ans[i]; cout << endl; return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:27:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(query(tmp)==tmp.size()) arr = tmp;
            ~~~~~~~~~~^~~~~~~~~~~~
carnival.cpp:29:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < arr.size(); i++) ans[arr[i]] = i+1;
                    ~~^~~~~~~~~~~~
carnival.cpp:49:30: warning: 'indx' may be used uninitialized in this function [-Wmaybe-uninitialized]
         ans[i] = ans[arr[indx]];
                              ^
#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...