답안 #541439

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
541439 2022-03-23T15:17:13 Z status_coding 사육제 (CEOI14_carnival) C++14
100 / 100
12 ms 292 KB
#include <bits/stdc++.h>

using namespace std;

int n,sz,nrG,nr;
int a[155];
vector<int> v[155];

int query(int id, int x)
{
    cout<<(int)v[id].size() + 1<<' ';
    for(int it : v[id])
        cout<<it<<' ';
    cout<<x;
    cout<<endl;

    int ans;
    cin>>ans;
    return ans;
}

int query2(int x, int y)
{
    cout<<2<<' '<<x<<' '<<y<<'\n';
    cout<<endl;

    int ans;
    cin>>ans;
    return ans;
}

int main()
{
    cin>>n;
    sz=sqrt(n);

    nrG=1;
    nr=1;
    a[1]=1;
    v[1].push_back(1);

    for(int i=2;i<=n;i++)
    {
        bool found = false;
        for(int j=1;j<=nrG;j++)
        {
            if(query(j, i) == (int)v[j].size())
            {
                found = true;

                for(int it : v[j])
                    if(query2(it, i) == 1)
                    {
                        a[i] = a[it];
                        break;
                    }

                break;
            }
        }

        if(!found)
        {
            nr++;
            a[i]=nr;

            if((int)v[nrG].size() == sz)
                nrG++;

            v[nrG].push_back(i);
        }
    }

    cout<<"0 ";
    for(int i=1;i<=n;i++)
        cout<<a[i]<<' ';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 12 ms 208 KB Output is correct
4 Correct 11 ms 208 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 3 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 10 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 11 ms 208 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 3 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 12 ms 208 KB Output is correct
5 Correct 5 ms 208 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 4 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 10 ms 208 KB Output is correct