| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1320791 | hoangmc2009 | Hidden Sequence (info1cup18_hidden) | C++17 | 2 ms | 400 KiB |
#include<bits/stdc++.h>
using namespace std;
#ifndef Graven
#include "grader.h"
#endif
#ifdef Graven
int maxQ=0;
vector<int> theRealAnswer;
bool isSubsequence(const vector<int>& v)
{
if (v.size()>maxQ) maxQ=v.size();
for(int i=0,j=0;i<v.size();++i)
{
while(j<theRealAnswer.size() and v[i]!=theRealAnswer[j]) ++j;
if(j==theRealAnswer.size()) return false;
else ++j;
}
return true;
}
#endif
vector<int> findSequence (int N)
{
if(N<=10)
{
for(int i=0;i<(1<<N);++i)
{
vector<int> wh;
for(int j=0;j<N;++j)
wh.push_back((i>>j)&1);
if(isSubsequence(wh)) return wh;
}
}
else return vector<int>(N,0);
}
#ifdef Graven
int main()
{
int n, x;
scanf ("%d", &n), maxQ = 0;
for (int i=1; i<=n; i++)
scanf ("%d", &x), theRealAnswer.push_back(x);
vector<int> ans=findSequence(n);
if (ans.size () != theRealAnswer.size ())
{
printf ("Different lengths\n");
for (auto it : ans) printf ("%d ", it);
printf ("\n");
return 0;
}
for (int i=0;i<ans.size();i++)
{
if (ans[i]!=theRealAnswer[i])
{
printf("WA position %d\n",i+1);
for (auto it : ans) printf ("%d ", it);
printf ("\n");
return 0;
}
}
printf ("Ok, biggest queried length %d\n", maxQ);
return 0;
}
#endif
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
