답안 #677565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
677565 2023-01-03T17:33:50 Z sofija6 사육제 (CEOI14_carnival) C++14
100 / 100
25 ms 336 KB
#include <bits/stdc++.h>
#define ll long long
#define MAXN 160
using namespace std;
ll d[MAXN];
ll Root(ll p)
{
    while (p!=d[p])
    {
        d[p]=d[d[p]];
        p=d[p];
    }
    return p;
}
void Join(ll p,ll q)
{
    d[Root(p)]=d[Root(q)];
}
int main()
{
    ///ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    for (ll i=1;i<=n;i++)
        d[i]=i;
    for (ll i=2;i<=n;i++)
    {
        ll l=1,r=i-1,mid,x,y;
        cout << i << " ";
        for (ll j=1;j<=i;j++)
            cout << j << " ";
        cout << "\n";
        cin >> x;
        cout << i-1 << " ";
        for (ll j=1;j<i;j++)
            cout << j << " ";
        cout << "\n";
        cin >> y;
        if (x!=y)
            continue;
        while (l<=r)
        {
            mid=(l+r)/2;
            cout << mid-l+1 << " ";
            for (ll j=l;j<=mid;j++)
                cout << j << " ";
            cout << "\n";
            cin >> x;
            cout << mid-l+2 << " ";
            for (ll j=l;j<=mid;j++)
                cout << j << " ";
            cout << i << "\n";
            cin >> y;
            if (y==1)
            {
                Join(i,mid);
                break;
            }
            if (x==y)
                r=mid;
            else
                l=mid+1;
        }
    }
    ll cnt=1;
    map<ll,ll> ans;
    cout << 0 << " ";
    for (ll i=1;i<=n;i++)
    {
        if (!ans[Root(i)])
        {
            ans[Root(i)]=cnt;
            cnt++;
        }
        cout << ans[Root(i)] << " ";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 208 KB Output is correct
2 Correct 15 ms 208 KB Output is correct
3 Correct 5 ms 328 KB Output is correct
4 Correct 8 ms 312 KB Output is correct
5 Correct 20 ms 208 KB Output is correct
6 Correct 12 ms 208 KB Output is correct
7 Correct 14 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 208 KB Output is correct
2 Correct 20 ms 208 KB Output is correct
3 Correct 11 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 23 ms 208 KB Output is correct
6 Correct 13 ms 208 KB Output is correct
7 Correct 22 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 21 ms 208 KB Output is correct
3 Correct 19 ms 208 KB Output is correct
4 Correct 5 ms 304 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 15 ms 300 KB Output is correct
7 Correct 15 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 208 KB Output is correct
2 Correct 21 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 6 ms 336 KB Output is correct
5 Correct 19 ms 292 KB Output is correct
6 Correct 11 ms 208 KB Output is correct
7 Correct 23 ms 280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 208 KB Output is correct
2 Correct 23 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 15 ms 292 KB Output is correct
6 Correct 12 ms 208 KB Output is correct
7 Correct 4 ms 300 KB Output is correct