Submission #44826

#TimeUsernameProblemLanguageResultExecution timeMemory
44826aomeHidden Sequence (info1cup18_hidden)C++17
100 / 100
148 ms584 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; int n, f[205]; void solve(int t, vector<int> &res) { int len = 0; vector<int> ask; for (int i = 1; i <= n / 2; ++i) { ask.assign(i, t); if (isSubsequence(ask)) len = i; } // suppose 0s < 1s f[len] = n - len; for (int i = 0; i < len; ++i) { int a = i, b = len - 1 - i; // a number of 0s to the left // b number of 0s to the right int c = 0, d = 0; // c number of 1s to the left // d number of 1s to the right // cout << "#at " << i << '\n'; while (a + d <= n / 2) { ask.clear(); for (int j = 0; j <= a; ++j) ask.push_back(t); for (int j = 0; j < d; ++j) ask.push_back(t ^ 1); if (!isSubsequence(ask)) break; d++; } while (b + c <= n / 2) { ask.clear(); for (int j = 0; j < c; ++j) ask.push_back(t ^ 1); for (int j = 0; j <= b; ++j) ask.push_back(t); if (!isSubsequence(ask)) break; c++; } c--, d--; // cout << c << ' ' << d << '\n'; if (a + d <= c + b) { f[i] = n - len - d; } else { f[i] = c; } } for (int i = len; i >= 1; --i) f[i] -= f[i - 1]; for (int i = 0; i < len; ++i) { for (int j = 0; j < f[i]; ++j) res.push_back(t ^ 1); res.push_back(t); } for (int i = 0; i < f[len]; ++i) res.push_back(t ^ 1); } vector<int> findSequence(int _n) { n = _n; vector<int> vec, res; vec.assign(n / 2 + 1, 0); if (isSubsequence(vec)) solve(1, res); else solve(0, res); return res; }

Compilation message (stderr)

grader.cpp: In function 'int main()':
grader.cpp:28:43: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     fprintf (fifo_out, "%d\n", ans.size ());
                                ~~~~~~~~~~~^
grader.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<ans.size () && i < N; i++)
                   ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...