답안 #447285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
447285 2021-07-25T20:06:13 Z LucaIlie 도서관 (JOI18_library) C++17
컴파일 오류
0 ms 0 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;
            ans = query( tak );
            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;
}*/

Compilation message

library.cpp: In function 'void solve(int)':
library.cpp:43:15: error: 'query' was not declared in this scope; did you mean 'Query'?
   43 |         ans = query( tak );
      |               ^~~~~
      |               Query
library.cpp:62:19: error: 'query' was not declared in this scope; did you mean 'Query'?
   62 |             ans = query( tak );
      |                   ^~~~~
      |                   Query
library.cpp:73:5: error: 'answer' was not declared in this scope; did you mean 'Answer'?
   73 |     answer( res );
      |     ^~~~~~
      |     Answer