Submission #451307

#TimeUsernameProblemLanguageResultExecution timeMemory
451307kingfran1907Carnival (CEOI14_carnival)C++14
100 / 100
20 ms312 KiB
#include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long llint; const int maxn = 2e5+10; const int base = 31337; const int mod = 1e9+7; const int inf = 0x3f3f3f3f; const int logo = 18; const int off = 1 << logo; const int treesiz = off << 1; int n; int niz[maxn]; int sol[maxn]; int query(vector< int > v) { printf("%d ", v.size()); for (int tren : v) printf("%d ", tren); printf("\n"); fflush(stdout); int x; scanf("%d", &x); return x; } int main() { scanf("%d", &n); vector< int > v; v.push_back(1); sol[1] = 1; for (int i = 2; i <= n; i++) { int lo = 0; int hi = v.size(); while (lo < hi) { int mid = (lo + hi + 1) / 2; vector< int > tren; for (int j = 0; j < mid; j++) tren.push_back(v[j]); tren.push_back(i); int out = query(tren); if (out == tren.size()) lo = mid; else hi = mid - 1; } if (lo == v.size()) { v.push_back(i); sol[i] = v.size(); } else sol[i] = sol[v[lo]]; } printf("0 "); for (int i = 1; i <= n; i++) printf("%d ", sol[i]); printf("\n"); fflush(stdout); return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int query(std::vector<int>)':
carnival.cpp:21:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   21 |  printf("%d ", v.size());
      |          ~^    ~~~~~~~~
      |           |          |
      |           int        std::vector<int>::size_type {aka long unsigned int}
      |          %ld
carnival.cpp: In function 'int main()':
carnival.cpp:50:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |    if (out == tren.size()) lo = mid;
      |        ~~~~^~~~~~~~~~~~~~
carnival.cpp:54:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   if (lo == v.size()) {
      |       ~~~^~~~~~~~~~~
carnival.cpp: In function 'int query(std::vector<int>)':
carnival.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d", &x);
      |  ~~~~~^~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  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...