Submission #98725

#TimeUsernameProblemLanguageResultExecution timeMemory
98725tmwilliamlin168Hidden Sequence (info1cup18_hidden)C++14
100 / 100
12 ms384 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; bool qry(int a, int b, int c) { vector<int> v(a, c); while(b--) v.push_back(c^1); return isSubsequence(v); } vector<int> findSequence(int n) { int c=0; for(int i=1; i<=n; ++i) { vector<int> v(i>n/2?n-i+1:i, i>n/2); if(qry(i>n/2?n-i+1:i, 0, i>n/2)^i<=n/2) break; c=i; } vector<int> ans; for(int i=1, j=0; i<=c; ++i) { for(; j<n-c; ++j) { if(j+c+1-i<=n/2?!qry(j+1, c+1-i, 1):qry(i, n-c-j, 0)) break; ans.push_back(1); } ans.push_back(0); } while(ans.size()<n) ans.push_back(1); return ans; }

Compilation message (stderr)

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:16:36: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   if(qry(i>n/2?n-i+1:i, 0, i>n/2)^i<=n/2)
                                   ~^~~~~
hidden.cpp:29:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(ans.size()<n)
        ~~~~~~~~~~^~
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...