Submission #975458

#TimeUsernameProblemLanguageResultExecution timeMemory
975458pavementHidden Sequence (info1cup18_hidden)C++17
100 / 100
13 ms696 KiB
#include "grader.h" #include <bits/stdc++.h> using namespace std; vector<int> findSequence(int N) { int minority; if (isSubsequence(vector<int>(N / 2 + 1, 0))) { minority = 1; } else { minority = 0; } int len = N / 2; for (; len >= 0; len--) { if (isSubsequence(vector<int>(len, minority))) { break; } } if (len == 0) { return vector<int>(N, !minority); } vector<int> ret(N, minority); for (int i = 1; i <= N - len; i++) { int b = i - 1, d = (N - len) - i, lo = 0, hi = N / 2 - d, a = N; while (lo <= hi) { int cur_a = (lo + hi) / 2, cur_c = len - cur_a; vector<int> to_ask(cur_a + d + 1, minority); fill(to_ask.begin() + cur_a, to_ask.end(), !minority); if (isSubsequence(to_ask)) { a = cur_a; lo = cur_a + 1; } else { hi = cur_a - 1; } } lo = 0, hi = N / 2 - b; int c = N; while (lo <= hi) { int cur_c = (lo + hi) / 2, cur_a = len - cur_c; vector<int> to_ask(b + cur_c + 1, minority); fill(to_ask.begin(), to_ask.begin() + b + 1, !minority); if (isSubsequence(to_ask)) { c = cur_c; lo = cur_c + 1; } else { hi = cur_c - 1; } } int x = (a == N / 2 - d || a == N ? len - c : a); ret[x + i - 1] = !minority; } return ret; }

Compilation message (stderr)

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:25:31: warning: unused variable 'cur_c' [-Wunused-variable]
   25 |    int cur_a = (lo + hi) / 2, cur_c = len - cur_a;
      |                               ^~~~~
hidden.cpp:38:31: warning: unused variable 'cur_a' [-Wunused-variable]
   38 |    int cur_c = (lo + hi) / 2, cur_a = len - cur_c;
      |                               ^~~~~
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...