Submission #1028491

# Submission time Handle Problem Language Result Execution time Memory
1028491 2024-07-20T02:47:52 Z ibm2006 None (JOI16_dungeon2) C++17
100 / 100
64 ms 79188 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++)
    {
        if(v[x][i]==-1)
        {
            u[x][i]=-1;
            continue;
        }
        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);
    //show();
    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:164:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  164 |             for(j=0;j<v[x].size();j++)
      |                     ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 34 ms 77912 KB Output is correct
2 Correct 35 ms 77912 KB Output is correct
3 Correct 35 ms 77912 KB Output is correct
4 Correct 34 ms 78044 KB Output is correct
5 Correct 35 ms 77916 KB Output is correct
6 Correct 34 ms 77916 KB Output is correct
7 Correct 35 ms 77992 KB Output is correct
8 Correct 35 ms 77904 KB Output is correct
9 Correct 34 ms 77916 KB Output is correct
10 Correct 36 ms 77972 KB Output is correct
11 Correct 34 ms 77904 KB Output is correct
12 Correct 37 ms 77904 KB Output is correct
13 Correct 35 ms 78008 KB Output is correct
14 Correct 35 ms 77876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 77908 KB Output is correct
2 Correct 35 ms 77916 KB Output is correct
3 Correct 35 ms 77916 KB Output is correct
4 Correct 36 ms 77864 KB Output is correct
5 Correct 36 ms 77908 KB Output is correct
6 Correct 34 ms 77916 KB Output is correct
7 Correct 35 ms 77984 KB Output is correct
8 Correct 35 ms 77904 KB Output is correct
9 Correct 35 ms 77908 KB Output is correct
10 Correct 36 ms 77944 KB Output is correct
11 Correct 35 ms 77904 KB Output is correct
12 Correct 36 ms 77908 KB Output is correct
13 Correct 34 ms 77916 KB Output is correct
14 Correct 35 ms 77908 KB Output is correct
15 Correct 35 ms 77912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 78164 KB Output is correct
2 Correct 35 ms 78164 KB Output is correct
3 Correct 47 ms 78432 KB Output is correct
4 Correct 54 ms 79184 KB Output is correct
5 Correct 37 ms 77916 KB Output is correct
6 Correct 35 ms 78160 KB Output is correct
7 Correct 36 ms 78160 KB Output is correct
8 Correct 36 ms 78376 KB Output is correct
9 Correct 36 ms 78424 KB Output is correct
10 Correct 36 ms 78164 KB Output is correct
11 Correct 36 ms 78160 KB Output is correct
12 Correct 36 ms 78160 KB Output is correct
13 Correct 39 ms 78416 KB Output is correct
14 Correct 36 ms 78168 KB Output is correct
15 Correct 38 ms 78232 KB Output is correct
16 Correct 38 ms 78324 KB Output is correct
17 Correct 54 ms 79188 KB Output is correct
18 Correct 64 ms 79184 KB Output is correct
19 Correct 54 ms 78988 KB Output is correct