Submission #973493

#TimeUsernameProblemLanguageResultExecution timeMemory
973493shoryu386Hidden Sequence (info1cup18_hidden)C++17
0 / 100
5 ms948 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; vector < int > findSequence (int N){ int A = 1, B = 0; vector<int> test; int numA = 0; for (int x = 1; x <= N/2+1; x++){ test.push_back(A); if (isSubsequence(test)){ numA++; } else break; } if (numA >= N/2+1){ swap(A, B); numA = 0; test.clear(); for (int x = 1; x <= N/2+1; x++){ test.push_back(A); if (isSubsequence(test)){ numA++; } else break; } } int filler[numA+1]; memset(filler, 0, sizeof(filler)); test.clear(); int cap = N/4; int marker = -1; for (int x = 0; x <= numA; x++){ while (true){ filler[x]++; test.clear(); if (filler[x] > cap){ filler[x] = 0; marker = x; break; } for (int y = 0; y < x; y++){ test.push_back(A); } for (int y = 0; y < filler[x]; y++){ test.push_back(B); } for (int y = 0; y < numA - x; y++){ test.push_back(A); } if (test.size() <= N && isSubsequence(test)){ continue; } else {filler[x]--; break;} } } int numB = N-numA; if (marker != -1){ int cursum = 0; for (int x = 0; x <= numA; x++){ cursum += filler[x]; } filler[marker] = numB - cursum; } test.clear(); for (int y = 0; y < numA; y++){ for (int z = 0; z < filler[y]; z++){ test.push_back(B); } test.push_back(A); } for (int z = 0; z < filler[numA]; z++){ test.push_back(B); } return test; }

Compilation message (stderr)

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:65:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   65 |    if (test.size() <= N && isSubsequence(test)){
      |        ~~~~~~~~~~~~^~~~
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...