Submission #447287

# Submission time Handle Problem Language Result Execution time Memory
447287 2021-07-25T20:13:13 Z LucaIlie Library (JOI18_library) C++17
0 / 100
41 ms 200 KB
#include <stdio.h>
#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;
}*/
# Verdict Execution time Memory Grader output
1 Correct 33 ms 200 KB # of queries: 2127
2 Correct 32 ms 200 KB # of queries: 2164
3 Correct 35 ms 200 KB # of queries: 2377
4 Correct 41 ms 200 KB # of queries: 2323
5 Correct 30 ms 200 KB # of queries: 2238
6 Correct 40 ms 200 KB # of queries: 2285
7 Correct 26 ms 200 KB # of queries: 2279
8 Correct 36 ms 200 KB # of queries: 2164
9 Correct 33 ms 200 KB # of queries: 2274
10 Correct 18 ms 200 KB # of queries: 1303
11 Runtime error 1 ms 200 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 200 KB # of queries: 2127
2 Correct 32 ms 200 KB # of queries: 2164
3 Correct 35 ms 200 KB # of queries: 2377
4 Correct 41 ms 200 KB # of queries: 2323
5 Correct 30 ms 200 KB # of queries: 2238
6 Correct 40 ms 200 KB # of queries: 2285
7 Correct 26 ms 200 KB # of queries: 2279
8 Correct 36 ms 200 KB # of queries: 2164
9 Correct 33 ms 200 KB # of queries: 2274
10 Correct 18 ms 200 KB # of queries: 1303
11 Runtime error 1 ms 200 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -