답안 #447289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
447289 2021-07-25T20:25:15 Z LucaIlie 도서관 (JOI18_library) C++17
0 / 100
40 ms 200 KB
#include <vector>
#include <library.h>

using namespace std;

int n;
vector<int> v, tak, res;

/*int Query( vector<int> m ) {
    int ans, i;

    for ( i = 0; i < n; i++ ) {
        if ( m[i] == 1 )
            printf( "%d ", i + 1 );
    }
    printf( "\n" );

    scanf( "%d", &ans );

    return ans;
}

void Answer( vector<int> m ) {
    int i;

    for ( i = 0; i < n; i++ )
        printf( "%d ", m[i] );
}*/

void Solve( int n ) {
    int ans, p, st, dr, mij, i, j;

    for ( i = 0; i < n; i++ )
        v.push_back( i );

    for ( i = 0; i < n; i++ )
        tak.push_back( 1 );
    ans = 2;
    i = 0;
    while ( ans == 2 ) {
        tak[v[i]] = 0;
        ans = Query( tak );
        tak[v[i]] = 1;
        i++;
    }
    res.push_back( v[i - 1] + 1 );
    p = i - 1;

    for ( i = 1; i < n; i++ ) {
        for ( j = p; j < n - (i - 1); j++ )
            v[j] = v[j + 1];
        st = 0;
        dr = n - i;
        while ( dr - st > 1 ) {
            mij = (st + dr) / 2;

            for ( j = 0; j < n; j++ )
                tak[j] = 0;
            for ( j = st; j < mij; j++ )
                tak[v[j]] = 1;
            if ( mij - st > 1 )
                ans = Query( tak );
            else if ( mij - st == 1 )
                ans = 1;
            else
                ans = 0;
            tak[res[i - 1] - 1] = 1;
            if ( Query( tak ) == ans )
                dr = mij;
            else
                st = mij;
        }
        res.push_back( v[st] + 1 );
        p = st;
    }

    Answer( res );
}

/*int main() {
    scanf( "%d", &n );
    Solve( n );
    return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 200 KB # of queries: 2127
2 Correct 30 ms 200 KB # of queries: 2164
3 Correct 37 ms 200 KB # of queries: 2377
4 Correct 32 ms 200 KB # of queries: 2323
5 Correct 31 ms 200 KB # of queries: 2238
6 Correct 40 ms 200 KB # of queries: 2285
7 Correct 35 ms 200 KB # of queries: 2279
8 Correct 40 ms 200 KB # of queries: 2164
9 Correct 21 ms 200 KB # of queries: 2274
10 Correct 18 ms 200 KB # of queries: 1303
11 Runtime error 0 ms 200 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 200 KB # of queries: 2127
2 Correct 30 ms 200 KB # of queries: 2164
3 Correct 37 ms 200 KB # of queries: 2377
4 Correct 32 ms 200 KB # of queries: 2323
5 Correct 31 ms 200 KB # of queries: 2238
6 Correct 40 ms 200 KB # of queries: 2285
7 Correct 35 ms 200 KB # of queries: 2279
8 Correct 40 ms 200 KB # of queries: 2164
9 Correct 21 ms 200 KB # of queries: 2274
10 Correct 18 ms 200 KB # of queries: 1303
11 Runtime error 0 ms 200 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -