답안 #724756

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724756 2023-04-15T22:50:21 Z hyakup 사육제 (CEOI14_carnival) C++17
100 / 100
8 ms 292 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 160;
int v[maxn];
int cont;

vector<int> lista;

bool queryInit( int id ){
    cout << lista.size() + 1 << " ";
    for( int x : lista ) cout << x << " ";
    cout << id << endl;
    cout.flush();
    
    int resp; cin >> resp;
    return ( resp == lista.size() + 1 );
}

bool query( int l, int r, int id ){
    cout << r - l + 2 << " ";
    for( int i = l; i <= r; i++ ) cout << lista[i] << " ";
    cout << id << endl;
    cout.flush();
    
    int resp; cin >> resp;
    return ( resp != r - l + 2 );
}

void solve( int id ){
    if( queryInit(id) ){ v[id] = ++cont; lista.push_back(id); return; }
    int l = 0, r = lista.size() - 1;
    while( l < r ){
        int mid = ( l + r )/2;
        if( query( l, mid, id ) ) r = mid;
        else l = mid + 1;
    }
    v[id] = v[lista[r]];
}

int main(){
    int n; cin >> n;
    for( int i = 1; i <= n; i++ ) solve(i);
    cout << 0 << " ";
    for( int i = 1; i <= n; i++ ) cout << v[i] << " ";
}

// 1 2 1 3 2








Compilation message

carnival.cpp: In function 'bool queryInit(int)':
carnival.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     return ( resp == lista.size() + 1 );
      |              ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 236 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 3 ms 292 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 6 ms 220 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 6 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 3 ms 208 KB Output is correct