Submission #1208037

#TimeUsernameProblemLanguageResultExecution timeMemory
1208037lopkusHidden Sequence (info1cup18_hidden)C++20
15 / 100
3 ms424 KiB
#include<bits/stdc++.h> #include "grader.h" using namespace std; int ask(std::vector<int> r) { return isSubsequence(r); } vector < int > findSequence (int n) { std::vector<int> t; for(int i = 1; i <= n / 2 + 1; i++) { t.push_back(1); } if(ask(t)) { // 0 is smaller int block = - 1; std::vector<int> E; while(ask(E)) { E.push_back(0); } E.pop_back(); std::vector<int> to(n + 1); for(int i = 0; i <= E.size(); i++) { std::vector<int> b = E; while(b.size() < n / 2 + 3) { b.insert(b.begin() + i, 1); } if(ask(b)) { to[i] = - 69; continue; } b = E; to[i] = - 1; while(b.size() < n / 2 + 3 && ask(b)) { b.insert(b.begin() + i, 1); to[i] += 1; } } std::vector<int> ans; int sum = n - E.size(); for(int i = 0; i <= E.size(); i++) { if(to[i] >= 0) { sum -= to[i]; } } int cnt = 0; for(int i = 0; i <= E.size(); i++) { if(to[i] == - 69) { cnt += 1; } } //assert(sum % cnt == 0); if(cnt > 0) { assert(sum % cnt == 0); sum /= cnt; } for(int i = 0; i <= E.size(); i++) { if(to[i] == - 69) { to[i] = sum; } } for(int i = 0; i < to[0]; i++) { ans.push_back(1); } for(int i = 1; i <= E.size(); i++) { ans.push_back(0); for(int j = 1; j <= to[i]; j++) { ans.push_back(1); } } return ans; } else { // 0 is smaller int block = - 1; std::vector<int> E; while(ask(E)) { E.push_back(1); } E.pop_back(); std::vector<int> to(n + 1); for(int i = 0; i <= E.size(); i++) { std::vector<int> b = E; while(b.size() < n / 2 + 3) { b.insert(b.begin() + i, 0); } if(ask(b)) { to[i] = - 69; continue; } b = E; to[i] = - 1; while(b.size() < n / 2 + 3 && ask(b)) { b.insert(b.begin() + i, 0); to[i] += 1; } } std::vector<int> ans; int sum = n - E.size(); for(int i = 0; i <= E.size(); i++) { if(to[i] >= 0) { sum -= to[i]; } } int cnt = 0; for(int i = 0; i <= E.size(); i++) { if(to[i] == - 69) { cnt += 1; } } //assert(sum % cnt == 0); if(cnt > 0) { assert(sum % cnt == 0); sum /= cnt; } for(int i = 0; i <= E.size(); i++) { if(to[i] == - 69) { to[i] = sum; } } for(int i = 0; i < to[0]; i++) { ans.push_back(0); } for(int i = 1; i <= E.size(); i++) { ans.push_back(1); for(int j = 1; j <= to[i]; j++) { ans.push_back(0); } } return ans; } } /** 10 0 1 1 0 0 0 1 1 1 1 **/

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
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...