답안 #595790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595790 2022-07-14T06:47:43 Z andrei_boaca 사육제 (CEOI14_carnival) C++14
100 / 100
10 ms 304 KB
#include <bits/stdc++.h>
 
using namespace std;
int n,c[155];
bool f[155];
int ask(int l,int r)
{
    cout<<r-l+1<<' ';
    for(int i=l;i<=r;i++)
        cout<<i<<' ';
    cout<<endl;
    int rez;
    cin>>rez;
    return rez;
}
int main()
{
    cin>>n;
    int nr=0;
    for(int i=1;i<=n;i++)
    {
        int ans=ask(1,i);
        if(ans>nr)
        {
            nr++;
            c[i]=nr;
            continue;
        }
        vector<int> poz;
        for(int j=1;j<=n;j++)
            f[j]=0;
        for(int j=i-1;j>=1;j--)
            if(f[c[j]]==0)
            {
                poz.push_back(j);
                f[c[j]]=1;
            }
        bool ok=0;
        if(i==10)
            ok=1;
        int st=0;
        int dr=poz.size();
        dr--;
        int pmax=0;
        while(st<=dr)
        {
            int mij=(st+dr)/2;
            ans=ask(poz[mij],i);
            if(ans==mij+2)
            {
                pmax=mij+1;
                st=mij+1;
            }
            else
                dr=mij-1;
        }
        c[i]=c[poz[pmax]];
    }
    cout<<"0 ";
    for(int i=1;i<=n;i++)
        cout<<c[i]<<' ';
    cout<<endl;
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:38:14: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   38 |         bool ok=0;
      |              ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 10 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 3 ms 304 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 10 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 8 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 8 ms 224 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct