# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67301 | hamzqq9 | Hidden Sequence (info1cup18_hidden) | C++14 | 11 ms | 564 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"
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2000000000
#define MOD 1000000007
#define MAX 10000006
#define LOG 22
using namespace std;
int MXQ;
bool query(vector<int> res) {
return isSubsequence(res);
}
int f1(int N) {
for(int i=1;i<=N;i++) {
vector<int> que;
if(i>MXQ) {
for(int j=0;j<N-i;j++) que.pb(0);
bool res=query(que);
if(res==true) return i-1;
}
else {
for(int j=0;j<i;j++) que.pb(1);
bool res=query(que);
if(res==false) return i-1;
}
}
return N;
}
vector < int > findSequence (int N) {
MXQ=N/2+1;
int h1=f1(N);
int h0=N-h1;
int p1=0;
int p0=0;
vector<int> ans;
for(int i=0;i<N;i++) {
// is it 1
vector<int> que;
if(p1+1+h0<=MXQ) {
for(int j=0;j<p1+1;j++) que.pb(1);
for(int j=0;j<h0;j++) que.pb(0);
bool res=query(que);
if(res) {
p1++;
h1--;
ans.pb(1);
}
else {
p0++;
h0--;
ans.pb(0);
}
}
else {
for(int j=0;j<p0+1;j++) que.pb(0);
for(int j=0;j<h1;j++) que.pb(1);
bool res=query(que);
if(res) {
p0++;
h0--;
ans.pb(0);
}
else {
p1++;
h1--;
ans.pb(1);
}
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |