Submission #660867

#TimeUsernameProblemLanguageResultExecution timeMemory
660867Bagritsevich_StepanHidden Sequence (info1cup18_hidden)C++14
100 / 100
74 ms416 KiB
#include <iostream> #include <vector> #include "grader.h" using namespace std; vector<int> findSequence(const int n) { const int maxlen = n / 2 + 1; int number = 1; vector<int> sequence; while (sequence.size() <= maxlen && isSubsequence(sequence)) { sequence.push_back(number); } sequence.pop_back(); if (sequence.size() == maxlen) { 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() <= maxlen && isSubsequence(sequence)) { sequence.insert(sequence.begin(), number ^ 1); } sequence.erase(sequence.begin()); vector<int> reversed_sequence(i + 1, number); while (reversed_sequence.size() <= maxlen && isSubsequence(reversed_sequence)) { reversed_sequence.push_back(number ^ 1); } reversed_sequence.pop_back(); int index = (int)sequence.size() - (countNumbers - i); if (reversed_sequence.size() < maxlen) { 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() <= maxlen && 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() == maxlen) {
      |         ~~~~~~~~~~~~~~~~^~~~~~~~~
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() <= maxlen && 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() <= maxlen && 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() < maxlen) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
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...