Submission #1096106

# Submission time Handle Problem Language Result Execution time Memory
1096106 2024-10-03T19:17:19 Z Tymond Crocodile's Underground City (IOI11_crocodile) C++17
46 / 100
3 ms 2908 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
using ll = long long;
using ld = long double;
#define fi first
#define se second
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int INF = 1e9;
const int MAXN = 1e5 + 7;
vector<pii> g[MAXN];
int vis[MAXN];
int f[MAXN];
int ans[MAXN];
int n, m;

int dfs(int v, int parent){
    vis[v] = 1;
    if(f[v]){
        ans[v] = 0;
        return ans[v];
    }
    ans[v] = INF;
    vi p;
    for(auto [u, c] : g[v]){
        if(u == parent){
            continue;
        }
        if(vis[u]){
            p.pb(ans[u] + c);
        }else{
            dfs(u, v);
            p.pb(ans[u] + c);
        }
    }

    sort(all(p));
    if(sz(p) > 1){
        ans[v] = min(ans[v], p[1]);
    }
    return ans[v];
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    n = N;
    m = M;
    for(int i = 0; i < K; i++){
        f[P[i]] = 1;
    }

    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]});
    }

    return dfs(0, 0);
}

/*int main(){
    int R[4][2] = {{0, 1}, {0, 2}, {3, 2}, {2, 4}};
    int L[4] = {2, 3, 1, 4};
    int P[3] = {1, 3, 4};
    cout << travel_plan(5, 4, R, L, 3, P);
    return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 1 ms 2892 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 1 ms 2892 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Correct 3 ms 2908 KB Output is correct
10 Incorrect 1 ms 2652 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 1 ms 2892 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Correct 3 ms 2908 KB Output is correct
10 Incorrect 1 ms 2652 KB Output isn't correct
11 Halted 0 ms 0 KB -