# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
486155 | leaked | Hidden Sequence (info1cup18_hidden) | C++14 | 11 ms | 328 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 sz(x) (int)x.size()
#define pb push_back
#define vec vector
vector < int > findSequence (int N)
{
vector<int>ans;
ans.pb(1);
int u=0;
// cout<<isSubsequence(ans)<<endl;
while(sz(ans)<=N && isSubsequence(ans)) u++,ans.pb(1);
ans.pop_back();
// for(auto &z : ans) cout<<z<<' ';
// cout<<endl;
int to=0;
if(sz(ans)>(N-sz(ans))){
int h=N-sz(ans);
ans.clear();
while(h--) ans.pb(0);
to=1;
}
for(int i=0;i<sz(ans);i++){
if(ans[i]==to) continue;
vec<int> nans=ans;
while(sz(nans)<N){
// cout<<"DEBUG"<<endl;
// for(auto &z : nans) cout<<z<<' ';
// cout<<endl;
nans.insert(nans.begin()+i,to);
if(!isSubsequence(nans)){
nans.erase(nans.begin()+i,nans.begin()+i+1);
break;
}
}
ans=nans;
}
while(sz(ans)!=N) ans.pb(to);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |