Submission #116651

#TimeUsernameProblemLanguageResultExecution timeMemory
116651roseanne_pcyCarnival (CEOI14_carnival)C++14
100 / 100
10 ms432 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; const int maxn = 155; vector<int> cand[maxn]; int col[maxn]; int ask(vector<int> vec) { printf("%d ", vec.size()); for(int x : vec) printf("%d ", x); printf("\n"); fflush(stdout); int res; scanf("%d", &res); return res; } int solve(vector<int> poss, int x) { if(poss.size() == 1) { return col[poss[0]]; } int lo = 0, hi = (int) poss.size()-1; int mid = (lo+hi)/2; vector<int> a1, a2; for(int i = 0; i<= hi; i++) { if(i<= mid) a1.pb(poss[i]); else a2.pb(poss[i]); } vector<int> send = a1; send.pb(x); int res = ask(send); if(res == send.size()) return solve(a2, x); return solve(a1, x); } int main() { int n; scanf("%d", &n); col[1] = 1; cand[1].pb(1); int lim = 1; for(int i = 2; i<= n; i++) { vector<int> send; for(int j = 1; j<= lim; j++) send.pb(cand[j].back()); send.pb(i); int res = ask(send); if(res == lim+1) { col[i] = lim+1; cand[lim+1].pb(i); lim++; continue; } send.pop_back(); col[i] = solve(send, i); cand[col[i]].pb(i); } printf("0 "); for(int i = 1; i<= n; i++) printf("%d ", col[i]); printf("\n"); fflush(stdout); }

Compilation message (stderr)

carnival.cpp: In function 'int ask(std::vector<int>)':
carnival.cpp:19:26: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d ", vec.size());
                ~~~~~~~~~~^
carnival.cpp: In function 'int solve(std::vector<int>, int)':
carnival.cpp:44:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(res == send.size()) return solve(a2, x);
     ~~~~^~~~~~~~~~~~~~
carnival.cpp: In function 'int ask(std::vector<int>)':
carnival.cpp:23:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int res; scanf("%d", &res);
           ~~~~~^~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d", &n);
         ~~~~~^~~~~~~~~~
#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...