Submission #433519

#TimeUsernameProblemLanguageResultExecution timeMemory
433519Lam_lai_cuoc_doiHidden Sequence (info1cup18_hidden)C++17
Compilation error
0 ms0 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; 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, 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) <= n / 2: we could checkstring (i * '0' + (n - j - total) * '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 = 0; i <= total; ++i) // the bit 0 now we're considering { for (; j <= n - total; ++j) { if (j + (total - i + 1) ? !Check(j, total - i + 1, 1) : Check(i, n - total - j, 0)) break; ans.emplace_back(1); } ans.emplace_back(0); } while (ans.size() < n) ans.emplace_back(1); return ans; }

Compilation message (stderr)

hidden.cpp: In function 'bool Check(int, int, int)':
hidden.cpp:18:12: error: 'isSubsequence' was not declared in this scope
   18 |     return isSubsequence(ans);
      |            ^~~~~~~~~~~~~
hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:71:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   71 |     while (ans.size() < n)
      |            ~~~~~~~~~~~^~~
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++)
      |                   ~^~~~~~~~~~~~