Submission #433522

#TimeUsernameProblemLanguageResultExecution timeMemory
433522Lam_lai_cuoc_doiHidden Sequence (info1cup18_hidden)C++17
100 / 100
10 ms428 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; constexpr bool typetest = 0; constexpr int N = 2e2 + 2; #include "grader.h" bool Check(int a, int b, int c) { vector<int> ans(a, c); while (b--) ans.emplace_back(c ^ 1); return isSubsequence(ans); } vector<int> findSequence(int n) { vector<int> ans; int total(0); // number of zero // count number of zero for (int i = 1; i <= n / 2 + 1; ++i) { if (!Check(i, 0, 0)) break; total = i; } if (total == n / 2 + 1) { total = 0; for (int i = 1; i <= n / 2 + 1; ++i) { if (!Check(i, 0, 1)) break; total = i; } total = n - total; } // Cal ans /* Let i is the bit 0 now we're considering (It means there are i - 1 filled - bits) j is the bit 1 now we're considering (It means there are j - 1 filled - bits) There are 2 cases: - if j + (total - i + 1) <= n / 2 + 1, we could check string (j * '1' + (total - i + 1) * '0') because the bit 0 before we don't need to care - if j + (total - i + 1) > n / 2 <-> n - j - total + i - 1 < n / 2 <-> i + (n - j - total + 1) <= n / 2 + 1: we could checkstring (i * '0' + (n - j - total + 1) * '1') because the string before the (i - 1) - 0 bit is defined so it's only necessary to check string after i - 0 bit */ for (int i = 1, j = 1; i <= total; ++i) // the bit 0 now we're considering { for (; j <= n - total; ++j) { if (j + (total - i + 1) <= n / 2 + 1 ? !Check(j, total - i + 1, 1) : Check(i, n - total - j + 1, 0)) break; ans.emplace_back(1); } ans.emplace_back(0); } while ((int)ans.size() < n) ans.emplace_back(1); return ans; }

Compilation message (stderr)

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