답안 #1085608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085608 2024-09-08T13:19:50 Z vjudge1 사육제 (CEOI14_carnival) C++17
100 / 100
5 ms 484 KB
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define int long long
#define ar array


const int N = 1e6 + 20;

int ask(vector<int> &v){
    cout<<v.size()<<" ";
    for(auto u: v)cout<<u<<" ";
    cout<<endl;
    int x;
    cin>>x;
    return x;
}

bool in(vector<int> v,int x){
    v.push_back(x);
    return ask(v) == (v.size() - 1);
}

signed main() {ios_base::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    int T = 1;
    vector<int> v = {1};
    int ans[n + 1];
    ans[1] = T++;
    for(int i = 2;i <= n;i++){
        if(!in(v, i)){
            ans[i] = T++;
            v.push_back(i);
            continue;
        }
        int lo = 0, hi = v.size() - 1, res = v.size() - 1;

        while(lo <= hi){
            int mid = (lo + hi) / 2;
            vector<int> u;
            for(int i = 0;i <= mid;i++)u.push_back(v[i]);
            if(in(u, i)){
                res = mid;
                hi = mid - 1;
            }else lo = mid + 1;
        }
        ans[i] = ans[v[res]];
    }
    cout<<"0 ";
    for(int i = 1;i <= n;i++)cout<<ans[i]<<" ";
    cout<<endl;
}

Compilation message

carnival.cpp: In function 'bool in(std::vector<long long int>, long long int)':
carnival.cpp:21:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     return ask(v) == (v.size() - 1);
      |            ~~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 3 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 3 ms 456 KB Output is correct
6 Correct 4 ms 452 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 3 ms 452 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct