Submission #666096

# Submission time Handle Problem Language Result Execution time Memory
666096 2022-11-27T15:29:35 Z bin9638 Carnival (CEOI14_carnival) C++17
100 / 100
23 ms 356 KB
#include<bits/stdc++.h>

using namespace std;
#define N 2112
#define ll long long
#define ii pair<int,int>
#define fs first
#define sc second
#define pb push_back

int kq[N],check[N],n,judge=2,ktr[N],dp[N];

struct DSU
{
    int lab[N];

    void init()
    {
        memset(lab,-1,sizeof(lab));
    }

    int root(int u)
    {
        if(lab[u]<0)
            return u;
        return(lab[u]=root(lab[u]));
    }

    void update(int u,int v)
    {
        if((u=root(u))==(v=root(v)))
            return;
        if(lab[u]>lab[v])
            swap(u,v);
        lab[u]+=lab[v];
        lab[v]=u;
    }
}T;

struct jury
{
    int a[N]={},cnt[N];

    void init()
    {
        cout<<"cc\n";
        for(int i=1;i<=n;i++)
            cin>>a[i];
    }

    int get()
    {
        int res=0;
        memset(cnt,0,sizeof(cnt));
        for(int i=1;i<=n;i++)
            if(ktr[i]==1)
            {
                if(++cnt[a[i]]==1)
                    res++;
            }
        return res;
    }
}jury;

void solve(int vt)
{
    int l=vt+1,r=n,pos=-1;
    while(l<=r)
    {
        int mid=(l+r)/2;
        memset(ktr,0,sizeof(ktr));
        for(int i=1;i<=n;i++)
            ktr[i]=(T.root(i)!=T.root(vt)&&i<=mid);
        int val,dem=0;
        for(int i=1;i<=n;i++)
            if(ktr[i])
                dem++;
        cout<<dem<<" ";
        for(int i=1;i<=n;i++)
            if(ktr[i])
                cout<<i<<" ";
        cout<<endl;
        if(judge==1)
            val=jury.get();
                else cin>>val;
        if(val==dp[mid])
        {
            pos=mid;
            r=mid-1;
        }else
            l=mid+1;
    }
    if(pos!=-1)
        T.update(pos,vt);
  //  cout<<vt<<" "<<pos<<endl;
}

int main()
{
   //// freopen("A.inp","r",stdin);
   //// freopen("A.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    if(judge==1)
        jury.init();
    T.init();
    for(int i=1;i<=n;i++)
    {
        ktr[i]=1;
        cout<<i<<" ";
        for(int j=1;j<=i;j++)cout<<j<<" ";cout<<endl;
        if(judge==1)
            dp[i]=jury.get();
                else cin>>dp[i];
    }
    for(int i=1;i<n;i++)
        solve(i);
    int dem=0;
    for(int i=1;i<=n;i++)
        if(check[i]==0)
        {
            dem++;
            for(int j=1;j<=n;j++)
                if(T.root(j)==T.root(i))
                {
                    kq[j]=dem;
                    check[j]=1;
                }
        }
    cout<<0<<" ";
    for(int i=1;i<=n;i++)
        cout<<kq[i]<<" ";
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:113:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  113 |         for(int j=1;j<=i;j++)cout<<j<<" ";cout<<endl;
      |         ^~~
carnival.cpp:113:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  113 |         for(int j=1;j<=i;j++)cout<<j<<" ";cout<<endl;
      |                                           ^~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 336 KB Output is correct
2 Correct 15 ms 352 KB Output is correct
3 Correct 16 ms 336 KB Output is correct
4 Correct 16 ms 348 KB Output is correct
5 Correct 12 ms 336 KB Output is correct
6 Correct 11 ms 336 KB Output is correct
7 Correct 14 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 336 KB Output is correct
2 Correct 17 ms 336 KB Output is correct
3 Correct 14 ms 336 KB Output is correct
4 Correct 20 ms 340 KB Output is correct
5 Correct 16 ms 336 KB Output is correct
6 Correct 12 ms 336 KB Output is correct
7 Correct 12 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 336 KB Output is correct
2 Correct 14 ms 340 KB Output is correct
3 Correct 19 ms 336 KB Output is correct
4 Correct 23 ms 340 KB Output is correct
5 Correct 15 ms 336 KB Output is correct
6 Correct 16 ms 336 KB Output is correct
7 Correct 15 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 352 KB Output is correct
2 Correct 14 ms 352 KB Output is correct
3 Correct 17 ms 356 KB Output is correct
4 Correct 17 ms 336 KB Output is correct
5 Correct 17 ms 336 KB Output is correct
6 Correct 15 ms 352 KB Output is correct
7 Correct 19 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 336 KB Output is correct
2 Correct 19 ms 352 KB Output is correct
3 Correct 17 ms 336 KB Output is correct
4 Correct 18 ms 336 KB Output is correct
5 Correct 19 ms 336 KB Output is correct
6 Correct 18 ms 352 KB Output is correct
7 Correct 20 ms 336 KB Output is correct