Submission #660868

#TimeUsernameProblemLanguageResultExecution timeMemory
660868Bagritsevich_StepanHidden Sequence (info1cup18_hidden)C++14
100 / 100
72 ms336 KiB
#include <iostream> #include <vector> #include "grader.h" using namespace std; vector<int> findSequence(const int n) { const int maxLength = n / 2 + 1; int number = 1; vector<int> sequence; while (sequence.size() <= maxLength && isSubsequence(sequence)) { sequence.push_back(number); } sequence.pop_back(); if (sequence.size() == maxLength) { number ^= 1; sequence.clear(); while (isSubsequence(sequence)) { sequence.push_back(number); } sequence.pop_back(); } const int countNumbers = (int)sequence.size(); vector<int> result(n, number ^ 1); for (int i = 0; i < countNumbers; i++) { while (sequence.size() <= maxLength && isSubsequence(sequence)) { sequence.insert(sequence.begin(), number ^ 1); } sequence.erase(sequence.begin()); vector<int> reversed_sequence(i + 1, number); while (reversed_sequence.size() <= maxLength && isSubsequence(reversed_sequence)) { reversed_sequence.push_back(number ^ 1); } reversed_sequence.pop_back(); int index = (int)sequence.size() - (countNumbers - i); if (reversed_sequence.size() < maxLength) { index = n - countNumbers - (reversed_sequence.size() - (i + 1)); } result[index + i] = number; sequence.pop_back(); } return result; }

Compilation message (stderr)

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:11:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   11 |     while (sequence.size() <= maxLength && isSubsequence(sequence)) {
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
hidden.cpp:16:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   16 |     if (sequence.size() == maxLength) {
      |         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
hidden.cpp:30:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   30 |         while (sequence.size() <= maxLength && isSubsequence(sequence)) {
      |                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
hidden.cpp:36:41: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   36 |         while (reversed_sequence.size() <= maxLength && isSubsequence(reversed_sequence)) {
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
hidden.cpp:42:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   42 |         if (reversed_sequence.size() < maxLength) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
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...