답안 #518715

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
518715 2022-01-24T13:11:29 Z LucaIlie Hidden Sequence (info1cup18_hidden) C++17
15 / 100
400 ms 524292 KB
#include <iostream>
#include <vector>
#include "grader.h"

using namespace std;

vector <int> vans;
vector <int> s;

bool ask( int nr0, int nr1, int f ) {
    s.clear();

    if ( nr0 + nr1 == 0 )
        return 1;

    if ( f == 0 ) {
        while ( nr0-- )
            s.push_back( 0 );
        while ( nr1-- )
            s.push_back( 1 );
    } else {
        while ( nr1-- )
            s.push_back( 1 );
        while ( nr0-- )
            s.push_back( 0 );
    }

    return isSubsequence( s );
}

void add( int b, int x ) {
    while ( x-- )
        vans.push_back( b );
}

vector <int> findSequence( int n ) {
    int nr0, nr1, b, zero, ram0, i;

    nr0 = 0;
    while ( nr0 <= n / 2 + 1 && ask( nr0, 0, 0 ) )
        nr0++;
    if ( nr0 == n / 2 + 2 ) {
        while ( !ask( 0, n - nr0, 0 ) )
            nr0++;
        nr1 = nr0;
        nr0 = n - nr0;
        b = 1;
    } else {
        nr0--;
        nr1 = n - nr0;
        b = 0;
    }

    ram0 = nr0;
    for ( i = 1; i <= nr1; i++ ) {
        zero = 0;
        while ( zero <= nr0 && ask( zero, i, !b ) )
            zero++;
        zero--;

        add( b, ram0 - zero );
        ram0 = zero;
        add( !b, 1 );
    }
    add( b, 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 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 = 6
5 Partially correct 1 ms 200 KB Output is partially correct: Maximum length of a query = 6
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 418 ms 524292 KB Time limit exceeded
2 Halted 0 ms 0 KB -