# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67298 | yusufake | Hidden Sequence (info1cup18_hidden) | C++14 | 13 ms | 588 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
#define mp make_pair
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef pair < int , int > pp;
typedef vector < int > vi;
const int mod = 1e9 + 7;
const int N = 1e3 + 3;
/*
static int maxQ = 0;
static vector < int > theRealAnswer;
bool isSubsequence (vector < int > v)
{
if (v.size () > maxQ)
maxQ = v.size ();
int i = 0;
for (auto it : v)
{
while (i < theRealAnswer.size () && it != theRealAnswer[i]) i ++;
if (i == theRealAnswer.size ()) return 0;
i ++;
}
return 1;
}
*/
vector < int > findSequence (int n){
vector < int > u,ans;
int i,j,h,k,lim,zz,it;
lim = 3*n/4;
for(i=0;i<=n/2;i++){
u.pb(1);
if(isSubsequence(u) == 0) break;
}
if(i <= n/2) { u.pop_back(); h = 1; k=i;}
else{
h = 0;
u.clear();
for(k=0; ;k++){
u.pb(0);
if(isSubsequence(u) == 0) break;
}
u.pop_back();
}
int kk = n-k;
int t=0,tt=0;
for(j=0;j<n;j++){
vector < int > v;
if(k + tt < kk + t){
for(i=1;i<=tt+1;i++) v.pb(!h);
for(i=1;i<=k;i++) v.pb(h);;
if(isSubsequence(v)) { ans.pb(!h); tt++; kk--; }
else { ans.pb(h); t++; k--; }
}
else{
for(i=1;i<=t+1;i++) v.pb(h);
for(i=1;i<=kk;i++) v.pb(!h);;
if(isSubsequence(v)) { ans.pb(h); t++; k--; }
else { ans.pb(!h); tt++; kk--; }
}
}
return ans;
}
/*
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;
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |