답안 #475738

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
475738 2021-09-23T23:35:19 Z soba 사육제 (CEOI14_carnival) C++14
20 / 100
115 ms 272 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int par[151], siz[151];
int fnd(int node)
{
    if(par[node]!=node)
    {
        return par[node]=fnd(par[node]);
    }
    return par[node]=node;
}
void uni(int a, int b)
{
    a=fnd(a);
    b=fnd(b);
    if(a==b)
        return;
    if(siz[a]>siz[b])
    {
        par[b]=a;
        siz[a]++;
    }
    else
    {
        par[a]=b;
        siz[b]++;
    }
    return ;
}
int main()
{
    int n;
    cin >> n;
    int start=1 , nxt , q;
    for(int i =1 ; i<= n ;i++)
    {
        siz[i]=1;
        par[i]=i;
    }
    while(start!=-1)
    {
        nxt=-1;
        for(int i= start+1 ; i<= n ;i++)
        {
            cout << 2 << " " << start << " " << i << "\n";
            cout.flush();
            cin >> q;
            if(q==1)
            {
                uni(start, i);
            }
            else
            {
                if(nxt==-1)
                    nxt=i;
            }
        }
        start=nxt;
    }
    int cnt=1;
    map<int,int>mp;
    for(int i =1 ; i<=n ; i++)
    {
        q=fnd(i);
        if(mp[q]==0)mp[q]=cnt++;
    }
    cout << 0 << " ";
    for(int i =1 ; i<=n ; i++)
    {
        q=fnd(i);
        cout <<mp[q] << " ";
    }
    cout <<"\n";
    cout.flush();
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 50 ms 200 KB Partially correct
2 Partially correct 90 ms 200 KB Partially correct
3 Partially correct 100 ms 272 KB Partially correct
4 Partially correct 75 ms 200 KB Partially correct
5 Partially correct 57 ms 200 KB Partially correct
6 Correct 4 ms 200 KB Output is correct
7 Partially correct 92 ms 200 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 60 ms 200 KB Partially correct
2 Partially correct 98 ms 200 KB Partially correct
3 Partially correct 41 ms 200 KB Partially correct
4 Partially correct 88 ms 200 KB Partially correct
5 Partially correct 56 ms 200 KB Partially correct
6 Correct 17 ms 200 KB Output is correct
7 Partially correct 72 ms 200 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 200 KB Output is correct
2 Partially correct 88 ms 200 KB Partially correct
3 Partially correct 72 ms 272 KB Partially correct
4 Partially correct 89 ms 272 KB Partially correct
5 Partially correct 76 ms 200 KB Partially correct
6 Partially correct 46 ms 200 KB Partially correct
7 Partially correct 107 ms 272 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 84 ms 200 KB Partially correct
2 Partially correct 38 ms 200 KB Partially correct
3 Partially correct 53 ms 272 KB Partially correct
4 Partially correct 93 ms 268 KB Partially correct
5 Partially correct 88 ms 268 KB Partially correct
6 Partially correct 59 ms 200 KB Partially correct
7 Partially correct 97 ms 200 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 61 ms 200 KB Partially correct
2 Partially correct 115 ms 200 KB Partially correct
3 Partially correct 92 ms 272 KB Partially correct
4 Partially correct 55 ms 200 KB Partially correct
5 Partially correct 98 ms 272 KB Partially correct
6 Partially correct 110 ms 200 KB Partially correct
7 Partially correct 115 ms 200 KB Partially correct