#include<bits/stdc++.h>
#include "grader.h"
#define pb push_back
using namespace std;
typedef vector<int>vi;
bool ask(vi v){return isSubsequence(v);}
int c0=0,c1=0;
vi buildL(int n){
int cur1=c1,cur0=c0;
vi ans;
while(ans.size()!=n){
if(cur1>cur0){
vi v;
for(int x:ans)
v.pb(x);
v.pb(1);
for(int i=0; i<cur0; i++)
v.pb(0);
if(ask(v))
ans.pb(1),cur1--;
else
ans.pb(0),cur0--;
}
else{
vi v;
for(int x:ans)
v.pb(x);
v.pb(0);
for(int i=0; i<cur1; i++)
v.pb(1);
if(ask(v))
ans.pb(0),cur0--;
else
ans.pb(1),cur1--;
}
}
return ans;
}
vi buildR(int n){
int cur1=c1,cur0=c0;
vi ans;
while(ans.size()!=n){
if(cur1>cur0){
vi v=vi(cur0,0);
v.pb(1);
for(int x:ans)
v.pb(x);
if(ask(v))
ans.insert(ans.begin(),1),cur1--;
else
ans.insert(ans.begin(),0),cur0--;
}
else{
vi v=vi(cur1,1);
v.pb(0);
for(int x:ans)
v.pb(x);
if(ask(v))
ans.insert(ans.begin(),0),cur0--;
else
ans.insert(ans.begin(),1),cur1--;
}
}
return ans;
}
vi findSequence (int n){
for(int i=1; ; i++){
vi all1=vi(i,1);
vi all0=vi(i,0);
if(!ask(all1)){
c1=i-1;
c0=n-c1;
break;
}
if(!ask(all0)){
c0=i-1;
c1=n-c1;
break;
}
}
vi L=buildL((n+1)/2),R=buildR(n/2);
vi ans;
for(int x:L)ans.pb(x);
for(int x:R)ans.pb(x);
return ans;
}
Compilation message
hidden.cpp: In function 'vi buildL(int)':
hidden.cpp:15:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
15 | while(ans.size()!=n){
| ~~~~~~~~~~^~~
hidden.cpp: In function 'vi buildR(int)':
hidden.cpp:48:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
48 | while(ans.size()!=n){
| ~~~~~~~~~~^~~
grader.cpp: In function 'int main()':
grader.cpp:28:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
28 | fprintf (fifo_out, "%d\n", ans.size ());
| ~^ ~~~~~~~~~~~
| | |
| int std::vector<int>::size_type {aka long unsigned int}
| %ld
grader.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for (int i=0; i<ans.size () && i < N; i++)
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
200 KB |
Output is partially correct: Maximum length of a query = 6 |
2 |
Partially correct |
1 ms |
200 KB |
Output is partially correct: Maximum length of a query = 8 |
3 |
Partially correct |
1 ms |
200 KB |
Output is partially correct: Maximum length of a query = 6 |
4 |
Partially correct |
1 ms |
200 KB |
Output is partially correct: Maximum length of a query = 8 |
5 |
Partially correct |
1 ms |
200 KB |
Output is partially correct: Maximum length of a query = 6 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
5 ms |
408 KB |
Output is partially correct: Maximum length of a query = 123 |
2 |
Partially correct |
5 ms |
328 KB |
Output is partially correct: Maximum length of a query = 133 |
3 |
Partially correct |
5 ms |
316 KB |
Output is partially correct: Maximum length of a query = 141 |
4 |
Partially correct |
5 ms |
304 KB |
Output is partially correct: Maximum length of a query = 111 |
5 |
Partially correct |
7 ms |
316 KB |
Output is partially correct: Maximum length of a query = 138 |
6 |
Partially correct |
5 ms |
312 KB |
Output is partially correct: Maximum length of a query = 109 |
7 |
Partially correct |
6 ms |
292 KB |
Output is partially correct: Maximum length of a query = 145 |
8 |
Partially correct |
5 ms |
300 KB |
Output is partially correct: Maximum length of a query = 113 |
9 |
Partially correct |
6 ms |
304 KB |
Output is partially correct: Maximum length of a query = 148 |
10 |
Partially correct |
7 ms |
328 KB |
Output is partially correct: Maximum length of a query = 153 |
11 |
Partially correct |
8 ms |
320 KB |
Output is partially correct: Maximum length of a query = 143 |
12 |
Partially correct |
7 ms |
312 KB |
Output is partially correct: Maximum length of a query = 150 |
13 |
Partially correct |
7 ms |
300 KB |
Output is partially correct: Maximum length of a query = 150 |