Submission #44829

#TimeUsernameProblemLanguageResultExecution timeMemory
44829cheater2kHidden Sequence (info1cup18_hidden)C++17
100 / 100
152 ms544 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; const int N = 225; int num = 0; int len = 0; int n; int t[N]; vector <int> findSequence(int _n) { n = _n; for (int k = 0; k < 2; ++k) { for (int i = 1; i <= (n / 2) + 1; ++i) { vector <int> vec; for (int j = 1; j <= i; ++j) vec.push_back(k); if (!isSubsequence(vec)) { num = k; len = i - 1; break; } } } if (!len) { vector <int> vec; for (int i = 1; i <= n; ++i) vec.push_back(num ^ 1); return vec; } for (int i = 1; i <= len; ++i) { // find the number of {num ^ 1} before the i-th {num} bool flag0, flag1; int lef0 = i - 1; int rig0 = len - i; int l = 0, r = 0; vector <int> vec; for (int j = 1; j <= (n / 2) - rig0; ++j) { // num ^ 1 (j times), num, num (rig0 times) vec.clear(); for (int k = 1; k <= j; ++k) vec.push_back(num ^ 1); vec.push_back(num); for (int k = 1; k <= rig0; ++k) vec.push_back(num); flag0 = isSubsequence(vec); if (flag0) ++l; else break; } for (int j = 1; j <= (n / 2) - lef0; ++j) { // num (lef0 times), num, num ^ 1 (j times) vec.clear(); for (int k = 1; k <= lef0; ++k) vec.push_back(num); vec.push_back(num); for (int k = 1; k <= j; ++k) vec.push_back(num ^ 1); flag1 = isSubsequence(vec); if (flag1) ++r; else break; } if (!flag1) t[i] = n - len - r; else t[i] = l; } vector <int> res; for (int i = 1; i <= len; ++i) { int add = t[i] - t[i - 1]; while(add--) res.push_back(num ^ 1); res.push_back(num); } int add = n - len - t[len]; while(add--) res.push_back(num ^ 1); return res; }

Compilation message (stderr)

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:64:3: warning: 'flag1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (!flag1) t[i] = n - len - r;
   ^~
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...