#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
int n,k;
vector<int>p,q;
void add(vector<int>& v,int x,int y){
for(int i=0; i<x ;i++) v.push_back(y);
}
int ask(vector<int>&v){
int res=isSubsequence(v);
p.clear();q.clear();
return res;
}
int cnt=0;
int a[201];
vector<int>findSequence(int N){
n=N;k=n/2+1;
add(p,k,0);
if(ask(p)){
for(int i=1; i<=k ;i++){
add(p,i,1);if(ask(p)) cnt=n-i;
}
}
else{
for(int i=1; i<=k ;i++){
add(p,i,0);if(ask(p)) cnt=i;
}
}
int sum=0;
for(int i=0; i<cnt ;i++){
for(int j=1; j+sum+cnt<=n ;j++){
add(p,sum+j,1);add(p,cnt-i,0);
add(q,i+1,0);add(q,n-cnt-sum-j+1,1);
int res;
if(p.size()>q.size()) res=1-ask(q);
else res=ask(p);
if(res) a[i]=j;
else break;
}
sum+=a[i];
}
a[cnt]=n-sum-cnt;
vector<int>ans;
for(int i=0; i<=cnt ;i++){
if(i!=0) ans.push_back(0);
for(int j=1; j<=a[i] ;j++) ans.push_back(1);
}
return ans;
}
Compilation message
grader.cpp: In function 'int main()':
grader.cpp:28:43: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
fprintf (fifo_out, "%d\n", ans.size ());
~~~~~~~~~~~^
grader.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<ans.size () && i < N; i++)
~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
396 KB |
Output is correct: Maximum length of a query = 5 |
2 |
Correct |
2 ms |
128 KB |
Output is correct: Maximum length of a query = 6 |
3 |
Correct |
3 ms |
256 KB |
Output is correct: Maximum length of a query = 5 |
4 |
Correct |
2 ms |
256 KB |
Output is correct: Maximum length of a query = 5 |
5 |
Correct |
2 ms |
256 KB |
Output is correct: Maximum length of a query = 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
256 KB |
Output is correct: Maximum length of a query = 83 |
2 |
Correct |
12 ms |
304 KB |
Output is correct: Maximum length of a query = 90 |
3 |
Correct |
8 ms |
256 KB |
Output is correct: Maximum length of a query = 96 |
4 |
Correct |
7 ms |
384 KB |
Output is correct: Maximum length of a query = 77 |
5 |
Correct |
7 ms |
384 KB |
Output is correct: Maximum length of a query = 95 |
6 |
Correct |
9 ms |
384 KB |
Output is correct: Maximum length of a query = 87 |
7 |
Correct |
9 ms |
384 KB |
Output is correct: Maximum length of a query = 97 |
8 |
Correct |
5 ms |
256 KB |
Output is correct: Maximum length of a query = 83 |
9 |
Correct |
9 ms |
384 KB |
Output is correct: Maximum length of a query = 101 |
10 |
Correct |
9 ms |
256 KB |
Output is correct: Maximum length of a query = 100 |
11 |
Correct |
5 ms |
408 KB |
Output is correct: Maximum length of a query = 96 |
12 |
Correct |
7 ms |
384 KB |
Output is correct: Maximum length of a query = 100 |
13 |
Correct |
10 ms |
256 KB |
Output is correct: Maximum length of a query = 101 |