Submission #410870

#TimeUsernameProblemLanguageResultExecution timeMemory
410870nichkeHidden Sequence (info1cup18_hidden)C++14
0 / 100
6 ms200 KiB
#include <bits/stdc++.h> #include <grader.h> using namespace std; bool isSubsequence(vector<int> vi); int cnt[2]; int done[2]; vector<int> findSequence(int N) { vector<int> ans(N); vector<int> tmp; for (int i = 0; i < (N + 1) / 2; i++) { tmp.push_back(0); if (!isSubsequence(tmp)) break; cnt[0]++; } tmp.clear(); for (int i = 0; i < (N + 1) / 2; i++) { tmp.push_back(1); if (!isSubsequence(tmp)) break; cnt[1]++; } if (cnt[0] < cnt[1]) { cnt[1] = N - cnt[0]; } else { cnt[0] = N - cnt[1]; } for (int i = N - 1; i >= 0; i--) { if (!cnt[0]) { ans[i] = 1; cnt[1]--; continue; } if (!cnt[1]) { ans[i] = 0; cnt[0]--; continue; } int bt = 1; if (cnt[0] + done[1] > cnt[1] + done[0]) { bt ^= 1; } tmp.clear(); for (int j = 0; j < cnt[bt ^ 1]; j++) tmp.push_back(bt ^ 1); for (int j = 0; j < done[bt]; j++) tmp.push_back(bt); ans[i] = (!isSubsequence(tmp)) ^ bt; done[ans[i]]++; cnt[ans[i]]--; } return ans; }

Compilation message (stderr)

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...