답안 #1028481

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028481 2024-07-20T02:35:31 Z ibm2006 Dungeon 2 (JOI16_dungeon2) C++17
컴파일 오류
0 ms 0 KB
#include "dungeon2.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
ll n,m,k,i,j,l,r,x,y,z,w,s,t,a[1100000],dp[1100000],ans[1100000],h[1100000],c[110000],b[110000],e;
queue<ll> q;
vector<ll> v[1100000],u[1100000],vv[1100000];
void make_dfstree(ll x,ll y)
{
    n++;

    if(h[x]==0)
    {h[x]=NumberOfRoads();
    for(i=0;i<h[x];i++)
    {
        v[x].push_back(0);
        u[x].push_back(0);
    }
    }
    if(y>0)
    v[x][LastRoad()-1]=-1;
    ll i,z;
    for(i=0;i<h[x];i++)
    {
        Move(i+1,2);
        z=Color();
        if(z==3)
        {
            v[x][i]=-1;
            u[x][i]=-1;
            Move(LastRoad(),3);
            continue;
        }
        else if(z==2)
        {
            v[x][i]=-1;
            u[x][i]=1;
            Move(LastRoad(),2);
            continue;
        }
        t++;
        z=LastRoad();
        v[x][i]=t;
        u[x][i]=-1;
        make_dfstree(t,x);
        Move(z,3);
    }
}
void g(ll x,ll y)
{
    ll i,z;
    for(i=0;i<h[x];i++)
    {
        if(v[x][i]<=0)
            continue;
        Move(i+1,a[x]);
        z=LastRoad();
        g(v[x][i],x);
        Move(z,a[v[x][i]]);
    }
}
void dfs(ll x,ll y)
{
    ll i;
    for(i=0;i<h[x];i++)
    {
        if(v[x][i]==-1&&u[x][i]>=0)
        {
            Move(i+1,Color());
            u[x][i]+=c[e]*(Color()-1);
            Move(LastRoad(),Color());
            continue;
        }
        if(v[x][i]==-1)
            continue;
        Move(i+1,Color());
        dfs(v[x][i],LastRoad());
    }
    if(y>0)
    {
        Move(y,a[x]);
    }
}
void Inspect(int R)
{
    c[0]=1;
    c[1]=3;
    c[2]=9;
    c[3]=27;
    c[4]=81;
    t=1;
    make_dfstree(1,0);
    for(i=1;i<=n;i++)
    {
        a[i]=(i-1)%3+1;
    }
    g(1,0);
    show();
    for(i=1;i<=n;i++)
        b[i]=i-1;
        /*for(i=1;i<=n;i++)
        {
            printf("%d:%d\n",i,h[i]);
            for(j=0;j<h[i];j++)
            {
                printf("(%d,%d) ",v[i][j],u[i][j]);
            }
            printf("\n");
        }*/
    for(e=0;e<=4;e++)
    {
        show();
        for(i=1;i<=n;i++)
        {
            b[i]/=3;
            a[i]=b[i]%3+1;
        }
        dfs(1,0);
    }
    for(i=1;i<=n;i++)
    {
        for(j=0;j<h[i];j++)
        {
            if(v[i][j]>0)
            {vv[i].push_back(v[i][j]);
            vv[v[i][j]].push_back(i);
            }
            if(u[i][j]>0)
            {
                vv[i].push_back(u[i][j]);
                vv[u[i][j]].push_back(i);
            }
        }
    }
    swap(vv,v);
    for(i=1;i<=n;i++)
    {
        sort(v[i].begin(),v[i].end());
        v[i].erase(unique(v[i].begin(),v[i].end()),v[i].end());
        h[i]=v[i].size();
        /*printf("%d: ",h[i]);
        for(j=0;j<h[i];j++)
            printf("%d ",v[i][j]);
        printf("\n");
    */}
    for(i=1;i<=n;i++)
    {
        q.push(i);
        for(j=1;j<=n;j++)
        {
            dp[j]=10000;
        }
        dp[i]=0;
        while(!q.empty())
        {
            x=q.front();
            q.pop();
            for(j=0;j<v[x].size();j++)
            {
                y=v[x][j];
                if(dp[v[x][j]]==10000)
                {
                    q.push(y);
                    dp[y]=dp[x]+1;
                }
            }
        }
        for(j=1;j<=n;j++)
        {
            ans[dp[j]]++;
        }
    }
    for(i=1;i<=R;i++)
        Answer(i,ans[i]/2);
}

Compilation message

dungeon2.cpp: In function 'void Inspect(int)':
dungeon2.cpp:98:5: error: 'show' was not declared in this scope
   98 |     show();
      |     ^~~~
dungeon2.cpp:158:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  158 |             for(j=0;j<v[x].size();j++)
      |                     ~^~~~~~~~~~~~