#include <iostream>
#include <vector>
#include "grader.h"
using namespace std;
vector <int> vans;
vector <int> seq;
bool ask( int nr0, int nr1, int s ) {
int i;
seq.clear();
if ( nr0 + nr1 == 0 )
return 1;
for ( i = 0; i < nr1; i++ )
seq.push_back( 1^s );
for ( i = 0; i < nr0; i++ )
seq.push_back( 0^s );
return isSubsequence( seq );
}
void add( int b, int x ) {
int i;
for ( i = 0; i < x; i++ )
vans.push_back( b );
}
vector <int> findSequence( int n ) {
int nr0, nr1, s, zero, ram0, i;
int l = 1, r = n + 1;
while ( r - l > 1 ) {
int mid = (l + r) / 2;
if ( ask( mid, 0, 0 ) )
l = mid;
else
r = mid;
}
nr0 = l;
if ( nr0 > n / 2 ) {
nr1 = nr0;
nr0 = n - nr0;
s = 1;
} else {
nr1 = n - nr0;
s = 0;
}
ram0 = nr0;
for ( i = 1; i <= nr1; i++ ) {
zero = 0;
while ( zero <= ram0 && ask( zero, i, s ) )
zero++;
zero--;
add( s, ram0 - zero );
ram0 = zero;
add( !s, 1 );
}
add( s, ram0 );
return vans;
}
Compilation message
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 |
1 ms |
344 KB |
Output is partially correct: Maximum length of a query = 6 |
2 |
Partially correct |
1 ms |
344 KB |
Output is partially correct: Maximum length of a query = 7 |
3 |
Correct |
0 ms |
344 KB |
Output is correct: Maximum length of a query = 5 |
4 |
Correct |
0 ms |
344 KB |
Output is correct: Maximum length of a query = 5 |
5 |
Partially correct |
0 ms |
344 KB |
Output is partially correct: Maximum length of a query = 5 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
37 ms |
600 KB |
Output is partially correct: Maximum length of a query = 124 |
2 |
Partially correct |
40 ms |
436 KB |
Output is partially correct: Maximum length of a query = 134 |
3 |
Partially correct |
45 ms |
440 KB |
Output is partially correct: Maximum length of a query = 99 |
4 |
Partially correct |
32 ms |
588 KB |
Output is partially correct: Maximum length of a query = 115 |
5 |
Partially correct |
38 ms |
432 KB |
Output is partially correct: Maximum length of a query = 101 |
6 |
Partially correct |
12 ms |
680 KB |
Output is partially correct: Maximum length of a query = 99 |
7 |
Partially correct |
36 ms |
692 KB |
Output is partially correct: Maximum length of a query = 127 |
8 |
Partially correct |
34 ms |
432 KB |
Output is partially correct: Maximum length of a query = 110 |
9 |
Partially correct |
45 ms |
700 KB |
Output is partially correct: Maximum length of a query = 127 |
10 |
Partially correct |
50 ms |
688 KB |
Output is partially correct: Maximum length of a query = 123 |
11 |
Correct |
51 ms |
436 KB |
Output is correct: Maximum length of a query = 96 |
12 |
Partially correct |
47 ms |
444 KB |
Output is partially correct: Maximum length of a query = 149 |
13 |
Partially correct |
50 ms |
692 KB |
Output is partially correct: Maximum length of a query = 105 |