Submission #96483

#TimeUsernameProblemLanguageResultExecution timeMemory
96483ASG1065Hidden Sequence (info1cup18_hidden)C++14
100 / 100
11 ms376 KiB
#include<bits/stdc++.h> #include "grader.h" std::vector <int> findSequence(int n) { std::vector <int> ans; std::vector <int> ones; std::vector<int> zeros; int zeroct; int onect; for (int i = 1; i <= std::floor(n/2)+1; ++i) { zeros.push_back(0); if (!isSubsequence(zeros)) { zeroct=i-1; onect=n-zeroct; break; } ones.push_back(1); if (!isSubsequence(ones)) { onect=i-1; zeroct=n-onect; break; } } int usedzeros = 0; int usedones = 0; for (int i = 0; i < n; ++i) { std::vector<int> guess; if (usedzeros+1+onect-usedones <= usedones+1+zeroct-usedzeros) { for (int j = 0; j < usedzeros+1; ++j) { guess.push_back(0); } for (int j = 0; j < onect-usedones; ++j) { guess.push_back(1); } if (isSubsequence(guess)) { ans.push_back(0); ++usedzeros; } else { ans.push_back(1); ++usedones; } } else { for (int j = 0; j < usedones+1; ++j) { guess.push_back(1); } for (int j = 0; j < zeroct-usedzeros; ++j) { guess.push_back(0); } if (isSubsequence(guess)) { ans.push_back(1); ++usedones; } else { ans.push_back(0); ++usedzeros; } } } return ans; }

Compilation message (stderr)

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:33:24: warning: 'onect' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if (usedzeros+1+onect-usedones <= usedones+1+zeroct-usedzeros)
             ~~~~~~~~~~~^~~~~~
hidden.cpp:33:53: warning: 'zeroct' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if (usedzeros+1+onect-usedones <= usedones+1+zeroct-usedzeros)
                                           ~~~~~~~~~~^~~~~~~
grader.cpp: In function 'int main()':
grader.cpp:28:43: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     fprintf (fifo_out, "%d\n", ans.size ());
                                ~~~~~~~~~~~^
grader.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<ans.size () && i < N; i++)
                   ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...