답안 #1085722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085722 2024-09-08T15:42:17 Z vjudge1 사육제 (CEOI14_carnival) C++17
100 / 100
6 ms 440 KB
#include <bits/stdc++.h>
using namespace std;
vector<int>v;
bool check2(int l,int r,int k)
{
    cout<<r-l+2<<" ";
    for(int i=l;i<=r;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<k<<endl;
    int a;
    cin>>a;
    if(a==r-l+2)
    {
        return true;
    }
    return false;
}
bool check(int k)
{
    cout<<v.size()+1<<" ";
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<k<<endl;
    int a;
    cin>>a;
    if(a==v.size()+1)
    {
        return true;
    }
    return false;
}
int main()
{
    int n,cnt=1;
    cin>>n;
    vector<int>res(n+1);
    res[1]=cnt++;
    v.push_back(1);
    for(int i=2;i<=n;i++)
    {
        if(check(i))
        {
            v.push_back(i);
            res[i]=cnt++;
        }
        else
        {
            int l=0,r=v.size()-1;
            while(l<r)
            {
                int m=(l+r)/2;
                if(check2(l,m,i))
                {
                    l=m+1;
                }
                else
                {
                    r=m;
                }
            }
            res[i]=res[v[l]];
        }
    }
    cout<<"0 ";
    for(int i=1;i<=n;i++)
    {
        cout<<res[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Compilation message

carnival.cpp: In function 'bool check(int)':
carnival.cpp:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
carnival.cpp:30:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     if(a==v.size()+1)
      |        ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 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 2 ms 344 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 3 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 2 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 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 4 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 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 2 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 4 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 6 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 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