Submission #1028482

# Submission time Handle Problem Language Result Execution time Memory
1028482 2024-07-20T02:36:11 Z ibm2006 None (JOI16_dungeon2) C++17
88 / 100
54 ms 79204 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: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++)
      |                     ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 38 ms 77916 KB Output is correct
2 Correct 34 ms 77908 KB Output is correct
3 Correct 33 ms 77996 KB Output is correct
4 Correct 33 ms 77904 KB Output is correct
5 Correct 31 ms 77916 KB Output is correct
6 Correct 34 ms 77904 KB Output is correct
7 Correct 33 ms 77908 KB Output is correct
8 Correct 32 ms 78172 KB Output is correct
9 Correct 32 ms 77908 KB Output is correct
10 Correct 32 ms 77988 KB Output is correct
11 Correct 36 ms 77904 KB Output is correct
12 Correct 35 ms 77916 KB Output is correct
13 Correct 34 ms 77916 KB Output is correct
14 Correct 33 ms 77908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 77916 KB Output is correct
2 Correct 32 ms 78100 KB Output is correct
3 Correct 33 ms 77912 KB Output is correct
4 Correct 32 ms 78068 KB Output is correct
5 Correct 35 ms 77916 KB Output is correct
6 Correct 32 ms 77916 KB Output is correct
7 Correct 33 ms 78036 KB Output is correct
8 Correct 32 ms 78072 KB Output is correct
9 Correct 38 ms 77924 KB Output is correct
10 Correct 32 ms 78020 KB Output is correct
11 Correct 34 ms 77944 KB Output is correct
12 Correct 34 ms 77916 KB Output is correct
13 Correct 35 ms 77916 KB Output is correct
14 Correct 35 ms 77960 KB Output is correct
15 Correct 33 ms 77912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 35 ms 78172 KB Partially correct
2 Partially correct 35 ms 78164 KB Partially correct
3 Partially correct 36 ms 78428 KB Partially correct
4 Partially correct 52 ms 79184 KB Partially correct
5 Partially correct 34 ms 77948 KB Partially correct
6 Partially correct 36 ms 78164 KB Partially correct
7 Partially correct 36 ms 78172 KB Partially correct
8 Partially correct 37 ms 78164 KB Partially correct
9 Partially correct 39 ms 78416 KB Partially correct
10 Partially correct 38 ms 78160 KB Partially correct
11 Partially correct 36 ms 78428 KB Partially correct
12 Partially correct 36 ms 78428 KB Partially correct
13 Partially correct 39 ms 78580 KB Partially correct
14 Partially correct 36 ms 78164 KB Partially correct
15 Partially correct 36 ms 78164 KB Partially correct
16 Partially correct 37 ms 78168 KB Partially correct
17 Partially correct 54 ms 79184 KB Partially correct
18 Partially correct 52 ms 79204 KB Partially correct
19 Partially correct 52 ms 79184 KB Partially correct