답안 #580624

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
580624 2022-06-21T14:39:06 Z andrei_boaca CEOI16_icc (CEOI16_icc) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;

int n;
vector<int> dsu[105];
int comp[105],a[105],b[105],asize,bsize;
int comps[105][105];
void dsu_merge(int c1,int c2)
{
    if(dsu[c1].size()<dsu[c2].size())
        swap(c1,c2);
    for(int i:dsu[c2])
    {
        comp[i]=c1;
        dsu[c1].push_back(i);
    }
    dsu[c2].clear();
}
void run(int N)
{
    n=N;
    for(int i=1;i<=n;i++)
    {
        dsu[i].push_back(i);
        comp[i]=i;
    }
    int nr=n;
    for(int z=1;z<n;z++,nr--)
    {
        cnt=0;
        for(int i=1;i<=n;i++)
            if(dsu[i].size())
            {
                cnt++;
                for(int j:dsu[i])
                    comp[j]=cnt;
                dsu[cnt]=dsu[i];
                dsu[i].clear();
            }
        int rad=sqrt(nr);
        int rest=nr%rad;
        int lg=0;
        for(int i=1;i<=nr;i++)
        {
            int l=rad;
            if(rest)
            {
                rest--;
                l++;
            }
            int j;
            lg++;
            int poz=0;
            for(j=i;j<=i+l-1;j++)
            {
                for(int q:dsu[j])
                    comps[lg][++poz]=q;
            }
            i=j;
        }
        int buck1=0,buck2=0;
        for(int i=1;i<=lg;i++)
        {
            int asize=0,bsize=0;
            for(int j=1;j<=n&&comps[i][j]!=0;j++)
                a[asize++]=comps[i][j];
            for(int j=1;j<=lg;j++)
                if(j!=i)
                {
                    for(int k=1;k<=n&&comps[j][k]!=0;k++)
                        b[bsize++]=comps[j][k];
                }
            int ans=query(asize,bsize,a,b);
            if(ans==1)
            {
                if(buck1==0)
                    buck1=i;
                else
                {
                    buck2=i;
                    break;
                }
            }
        }
        int L=0;
        for(int i=1;i<=n&&comps[buck1][i]!=0;i++,L++);
        int st=1;
        int dr=L;
        int x=0;
        while(st<=dr)
        {
            int mij=(st+dr)/2;
            int asize=0;
            for(int i=1;i<=mij;i++)
                a[asize++]=comps[buck1][i];
            int bsize=0;
            for(int i=1;i<=n&&comps[buck2][i]!=0;i++)
                b[bsize++]=comps[buck2][i];
            int ans=query(asize,bsize,a,b);
            if(ans==1)
            {
                x=mij;
                dr=mij-1;
            }
            else
                st=mij+1;
        }
        L=0;
        for(int i=1;i<=n&&comps[buck2][i]!=0;i++,L++);
        st=1;
        dr=L;
        int y=0;
        while(st<=dr)
        {
            int mij=(st+dr)/2;
            int asize=0;
            for(int i=1;i<=mij;i++)
                a[asize++]=comps[buck2][i];
            int bsize=0;
            for(int i=1;i<=n&&comps[buck1][i]!=0;i++)
                b[bsize++]=comps[buck1][i];
            int ans=query(asize,bsize,a,b);
            if(ans==1)
            {
                y=mij;
                dr=mij-1;
            }
            else
                st=mij+1;
        }
        dsu_merge(comp[x],comp[y]);
        setRoad(x,y);
    }
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:31:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   31 |         cnt=0;
      |         ^~~
      |         int