Submission #1003318

# Submission time Handle Problem Language Result Execution time Memory
1003318 2024-06-20T08:55:31 Z vjudge1 Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
0 ms 344 KB
#include "crocodile.h"
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define f first
#define s second
#define pb push_back
#define p_b pop_back
using namespace std;
const int sz = 1e3+5;
vector<pii>g[sz];
int vis[sz], dist[sz], ans = INT_MAX, ext[sz], R[sz][2];
void dfs(int node)
{
    vis[node] = 1;
    vector<pii>vect;
    ll k = 0;
    for(auto u : g[node])
    {
        if(vis[u.f])
            continue;
        dist[u.f] = dist[node] + u.s;
        if(ext[u.f])
            k++;
        vect.pb({dist[u.f], u.f});
    }
    sort(all(vect));
    if(k <= 1){
        for(auto u : vect)
        {
            if(vis[u.s])
                continue;
            dfs(u.s);
        }
    }
    else
    {
        ll cnt = 0;
        for(auto u : vect)
        {
            if(ext[u.s])
                cnt++;
            if(cnt == 2)
                ans = min(ans, u.f);
        }
    }
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    for(int i = 0; i < M; i++)
    {
        g[R[i][0]].pb({R[i][1], L[i]});
        g[R[i][1]].pb({R[i][0], L[i]});
    }
    for(int i = 0; i < K; i++)
        ext[P[i]] = 1;
    int res = 0;
    dfs(0);
    return ans;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:63:9: warning: unused variable 'res' [-Wunused-variable]
   63 |     int res = 0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -