# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105151 | 2019-04-10T17:45:37 Z | stefdasca | Hidden Sequence (info1cup18_hidden) | C++14 | 12 ms | 384 KB |
#include<bits/stdc++.h> #include "grader.h" using namespace std; vector<int>findSequence(int N) { vector<int> ans (N, 0); vector<int> qu; vector<int> qu1; int nr0 = 0, nr1 = 0; while(1) { qu.push_back(0); qu1.push_back(1); if(isSubsequence(qu)) ++nr0; else { nr1 = N - nr0; break; } if(isSubsequence(qu1)) ++nr1; else { nr0 = N - nr1; break; } } int cntsf0 = 0, cntsf1 = 0; for(int i = 0; i < N; ++i) { qu.clear(); if(cntsf0 < cntsf1) { for(int j = 0; j < cntsf0; ++j) qu.push_back(0); if(i && ans[i-1] == 1) qu.push_back(1); } else { for(int j = 0; j < cntsf1; ++j) qu.push_back(1); if(i && ans[i-1] == 0) qu.push_back(0); } if(nr0 <= nr1) { qu.push_back(1); for(int j = 0; j < nr0; ++j) qu.push_back(0); if(isSubsequence(qu)) ans[i] = 1, ++cntsf1, --nr1; else ans[i] = 0, ++cntsf0, --nr0; } else { qu.push_back(0); for(int j = 0; j < nr1; ++j) qu.push_back(1); if(isSubsequence(qu)) ans[i] = 0, ++cntsf0, --nr0; else ans[i] = 1, ++cntsf1, --nr1; } } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 3 ms | 384 KB | Output is partially correct: Maximum length of a query = 6 |
2 | Partially correct | 3 ms | 384 KB | Output is partially correct: Maximum length of a query = 7 |
3 | Partially correct | 2 ms | 384 KB | Output is partially correct: Maximum length of a query = 6 |
4 | Correct | 2 ms | 256 KB | Output is correct: Maximum length of a query = 5 |
5 | Incorrect | 2 ms | 256 KB | Output is not correct: The returned sequence does not match the hidden one |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 384 KB | Output is not correct: The returned sequence does not match the hidden one |
2 | Halted | 0 ms | 0 KB | - |