Submission #130280

# Submission time Handle Problem Language Result Execution time Memory
130280 2019-07-14T16:48:49 Z DodgeBallMan Carnival (CEOI14_carnival) C++14
0 / 100
25 ms 504 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 200;
int n, c, mark[N];
vector<int> all;
int ask( vector<int> v ) {
    int ret;
    printf("%d ",v.size() );
    for( int i = 0 ; i < ( int )v.size() - 1 ; i++ ) printf("%d ",v[i]);
    printf("%d\n",v[(int)v.size()-1]);
    fflush( stdout );
    scanf("%d",&ret);
    return ret;
}

void process( int l, int r, int nu ) {
    //printf("L : %d R : %d\n",l,r);
    if( l == r ) {
        mark[all[l]] = c;
        return ;
    }
    int mid = ( l + r ) >> 1;
    vector<int> v, v2;
    for( int i = l ; i <= mid ; i++ ) v.emplace_back( all[i] );
    for( int i = mid+1 ; i <= r ; i++ ) v2.emplace_back( all[i] );
    int a = ask( v ), b = ask( v2 );
    v.emplace_back( nu ), v2.emplace_back( nu );
    int c = ask( v ), d = ask( v2 );
    //printf("%d %d %d %d\n",a,b,c,d);
    if( a == c ) process( l, mid, nu );
    if( b == d ) process( mid + 1, r, nu );
}

int main()
{
    scanf("%d",&n);
    for( int i = 1 ; i <= n ; i++ ) all.emplace_back( i );
    for( int i = 1 ; i <= n ; i++ ) if( !mark[i] ) {
        ++c;
        all.erase( all.begin() );
        mark[i] = c;
        int x = all.size();
        if( x == 0 ) break;
        process( 0, x-1, i );
        all.clear();
        for( int j = 1 ; j <= n ; j++ ) if( !mark[j] ) all.emplace_back( j );
    }
    printf("0 ");
    for( int i = 1 ; i <= n ; i++ ) printf("%d ",mark[i]);
    return 0;
}

Compilation message

carnival.cpp: In function 'int ask(std::vector<int>)':
carnival.cpp:10:27: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d ",v.size() );
                  ~~~~~~~~ ^
carnival.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&ret);
     ~~~~~^~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 17 ms 248 KB Output is correct
2 Correct 21 ms 376 KB Output is correct
3 Incorrect 15 ms 376 KB Incorrect
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 376 KB Output is correct
2 Correct 25 ms 248 KB Output is correct
3 Incorrect 13 ms 248 KB Incorrect
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 380 KB Output is correct
2 Correct 9 ms 376 KB Output is correct
3 Correct 24 ms 376 KB Output is correct
4 Incorrect 8 ms 376 KB Incorrect
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 248 KB Output is correct
2 Correct 15 ms 248 KB Output is correct
3 Correct 17 ms 376 KB Output is correct
4 Incorrect 12 ms 248 KB Incorrect
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 376 KB Output is correct
2 Correct 13 ms 248 KB Output is correct
3 Incorrect 20 ms 504 KB Incorrect
4 Halted 0 ms 0 KB -