답안 #995996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995996 2024-06-10T06:54:42 Z vjudge1 사육제 (CEOI14_carnival) C++14
100 / 100
5 ms 600 KB
#include<bits/stdc++.h>
using namespace std;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> first;
    int input;
    first.push_back(1);
    for(int i=2;i<=n;i++){
        cout << first.size()+1 << ' ';
        for(int j=0;j<first.size();j++){
            cout << first[j] << ' ';
        }
        cout << i << endl;
        cin >> input;
        if(input==first.size()+1){
            first.push_back(i);
        }
    }
    int ans[n+1];
    memset(ans,0,sizeof(ans));
    for(int i=0;i<first.size();i++){
        ans[first[i]]=i+1;
    }
    for(int i=1;i<=n;i++){
        if(ans[i]!=0){
            continue;
        }
        int low=1,high=first.size();
        low--;
        high++;
        while(high-low>1){
            int mid=(high-low)/2+low;
            cout << mid+1 << ' ';
            for(int j=0;j<mid;j++){
                cout << first[j] << ' ';
            }
            cout << i << endl;
            cin >> input;
            if(input==mid+1){
                low=mid;
            }
            else{
                high=mid;
            }
        }
        ans[i]=high;
    }
    cout << "0";
    for(int i=1;i<=n;i++){
        cout << ' ' << ans[i];
    }
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         for(int j=0;j<first.size();j++){
      |                     ~^~~~~~~~~~~~~
carnival.cpp:18:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if(input==first.size()+1){
      |            ~~~~~^~~~~~~~~~~~~~~~
carnival.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0;i<first.size();i++){
      |                 ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 2 ms 344 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 4 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 4 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 4 ms 344 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 3 ms 344 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 3 ms 344 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 3 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct