Submission #725314

# Submission time Handle Problem Language Result Execution time Memory
725314 2023-04-17T08:38:06 Z onepunchac168 Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
2 ms 2688 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define ll long long
typedef pair <ll,ll> ii;
typedef pair <ll ,ii> iii;
const char nl='\n';
ii dp[100005][2];
vector <int > gg;
vector <ii> vt[100005];
int n;
int dijkstra()
{
    for (int i=0;i<n;i++)
    {
        dp[i][0]=dp[i][1]={1e18+5,-1};
    }
    priority_queue<iii,vector <iii> ,greater <iii> > qu;
    for (auto v:gg)
    {
        dp[v][0]=dp[v][1]={0,-1};
        qu.push({0,{v,1}});
    }
    while (!qu.empty())
    {
        int aa=qu.top().fi;
        int u=qu.top().se.fi;
        int pos=qu.top().se.se;
        qu.pop();
        if (u==0&&pos==1)
        {
            return aa;
        }
        if (aa!=dp[u][pos].fi){continue;}
        for (auto v:vt[u])
        {
            if (dp[v.fi][0].fi>dp[u][pos].fi+v.se)
            {
                if (dp[v.fi][1].fi>dp[v.fi][0].fi)
                {
                    dp[v.fi][1]=dp[v.fi][0];
                    qu.push({dp[v.fi][1].fi,{v.fi,1}});
                }
                else
                {
                    dp[v.fi][0]={dp[u][pos].fi+v.se,u};
                }

            }
            else if (dp[v.fi][1].fi>dp[u][pos].fi+v.se)
            {
                dp[v.fi][1]={dp[u][pos].fi+v.se,u};
                qu.push({dp[v.fi][1].fi,{v.fi,1}});
            }
        }

    }

}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    n=N;
    for (int i=0;i<M;i++)
    {
        int aa=R[i][0];
        int bb=R[i][1];
        int cc=L[i];
        vt[aa].pb({bb,cc});
        vt[bb].pb({aa,cc});
    }
    for (int i=0;i<K;i++)
    {
        gg.pb(P[i]);
    }
    return dijkstra();

}

Compilation message

crocodile.cpp: In function 'int dijkstra()':
crocodile.cpp:22:54: warning: control reaches end of non-void function [-Wreturn-type]
   22 |     priority_queue<iii,vector <iii> ,greater <iii> > qu;
      |                                                      ^~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -