Submission #156598

# Submission time Handle Problem Language Result Execution time Memory
156598 2019-10-06T15:04:11 Z Linca_Robert Carnival (CEOI14_carnival) C++14
100 / 100
32 ms 504 KB
#include<bits/stdc++.h>
using namespace std;

int N, C, ans[256], f[256], cnt;
vector<int> qry;

inline void get_cul( int pos ){
    qry.clear();
    for( int i = 1; i <= cnt; i++ )
        qry.push_back( i );
    random_shuffle( qry.begin(), qry.end() );
    bool ok = false;
    while( ok == false && qry.size() != 1 ){
        int p = rand() % ( (int)(qry.size()) );
        cout << "2 " << f[ qry[p] ] << " " << pos << endl;
        int x; cin >> x;
        if( x == 1 ){
            ans[pos] = qry[p];
            ok = true;
        }else{
            if( p != (int)(qry.size() - 1) )
                swap( qry[p], qry[ qry.size() - 1 ] );
            qry.pop_back();
        }
    }
    if( ok == false )
        ans[pos] = qry[0];
    return ;
}

inline int get_ans( void ){
    cout << (int)(qry.size()) << " ";
    for( int i = 0; i < qry.size(); i++ )
        cout << qry[i] << " ";
    cout << endl;
    int x; cin >> x;
    return x;
}

int main(){
    srand( time(0) );
    cin >> N;
    for( int i = 1; i <= N; i++ )
        qry.push_back( i );
    C = get_ans();
    f[1] = 1;
    cnt = 1;
    ans[1] = 1;
    for( int i = 2; i <= N; i++ ){
        if( cnt < C ){
            qry.clear();
            for( int j = 1; j <= i; j++ )
                qry.push_back( j );
            int x = get_ans();
            if( x == cnt + 1 )
                cnt++, f[cnt] = i, ans[i] = cnt;
            else
                get_cul( i );
        }else
            get_cul( i );
    }
    cout << "0 ";
    for( int i = 1; i <= N; i++ )
        cout << ans[i] << " ";
    return 0;
}

Compilation message

carnival.cpp: In function 'int get_ans()':
carnival.cpp:33:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for( int i = 0; i < qry.size(); i++ )
                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 248 KB Output is correct
2 Correct 23 ms 248 KB Output is correct
3 Correct 18 ms 248 KB Output is correct
4 Correct 7 ms 248 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 19 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 20 ms 376 KB Output is correct
3 Correct 16 ms 376 KB Output is correct
4 Correct 9 ms 376 KB Output is correct
5 Correct 6 ms 248 KB Output is correct
6 Correct 10 ms 248 KB Output is correct
7 Correct 13 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 9 ms 248 KB Output is correct
3 Correct 32 ms 504 KB Output is correct
4 Correct 8 ms 248 KB Output is correct
5 Correct 12 ms 376 KB Output is correct
6 Correct 16 ms 376 KB Output is correct
7 Correct 21 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 7 ms 248 KB Output is correct
3 Correct 17 ms 376 KB Output is correct
4 Correct 5 ms 248 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 17 ms 248 KB Output is correct
7 Correct 12 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 14 ms 248 KB Output is correct
3 Correct 25 ms 248 KB Output is correct
4 Correct 11 ms 376 KB Output is correct
5 Correct 19 ms 376 KB Output is correct
6 Correct 14 ms 248 KB Output is correct
7 Correct 6 ms 296 KB Output is correct