#include<bits/stdc++.h>
#include "grader.h"
#define pb push_back
using namespace std;
typedef vector<int>vi;
int mx_len=0;
bool ask(vi v){
mx_len=max(mx_len,int(v.size()));
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-c0;
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);
assert(mx_len<=n/2 +10);
return ans;
}
Compilation message
hidden.cpp: In function 'vi buildL(int)':
hidden.cpp:19:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
19 | while(ans.size()!=n){
| ~~~~~~~~~~^~~
hidden.cpp: In function 'vi buildR(int)':
hidden.cpp:51:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
51 | 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++)
| ~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 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 |
0 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 = 6 |
5 |
Partially correct |
0 ms |
200 KB |
Output is partially correct: Maximum length of a query = 6 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
440 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |