Submission #923206

#TimeUsernameProblemLanguageResultExecution timeMemory
923206IanisHidden Sequence (info1cup18_hidden)C++17
100 / 100
2 ms856 KiB
#include<bits/stdc++.h> #include "grader.h" using namespace std; #define sz(a) int((a).size()) #define all(a) (a).begin(), (a).end() vector<int> operator+(vector<int> dest, const vector<int> &src) { for (auto &it : src) dest.push_back(it); return dest; } vector<int> rev(vector<int> v) { reverse(all(v)); return v; } bool flipped; int cnt[2], used[2]; vector<int> findSequence(int n) { vector<int> pref, suff; if (isSubsequence(vector(n / 2 + 1, 0))) flipped = true; for (int i = n / 2; i >= 1; i--) { if (isSubsequence(vector<int>(i, flipped))) { cnt[flipped] = i; break; } } cnt[!flipped] = n - cnt[flipped]; vector<int> ans; while (int(ans.size()) < n) { vector<int> s; if (used[0] + cnt[1] - used[1] < used[1] + cnt[0] - used[0]) { s = vector<int>(used[0] + 1, 0) + vector<int>(cnt[1] - used[1], 1); if (isSubsequence(s)) ans.push_back(0); else ans.push_back(1); } else { s = vector<int>(used[1] + 1, 1) + vector<int>(cnt[0] - used[0], 0); if (isSubsequence(s)) ans.push_back(1); else ans.push_back(0); } used[ans.back()]++; } 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...