답안 #649368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
649368 2022-10-10T06:28:32 Z mychecksedad 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
28 ms 55380 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long int ll;
const int X = 1e6, MOD = 1e9+7;



int n, m;
vector<ll> dist[X], dp(X);
vector<pair<int, ll>> g[X];
bitset<X> is, vis;

void dfs(int v, int p){
    if(is[v]){
        return;
    }
    vis[v] = 1;
    vector<pair<ll, int>> dist;
    for(auto k: g[v]){
        int u = k.first, e = k.second;
        if(u == p) continue;
        if(!vis[u])
            dfs(u, v);
        dist.pb({dp[u] + e, u});
    }
    sort(dist.begin(), dist.end());
    for(auto k: g[v]){
        int u = k.first, e = k.second;
        if(u == p) continue;

        ll d;
        if(dist[0].second == u){
            if(dist.size() > 1)
                d = dist[1].first;
            else
                d = MOD;
        }else{
            d = dist[0].first;
        }
        dp[v] = max(dp[v], d);
    }
}

int travel_plan(int F, int M, int R[][2], int L[], int K, int P[]){ 
    n = F;
    m = M;
    for(int i = 0; i < K; ++i) is[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]});
    }
    dfs(0, 0);

    return dp[0];
}

Compilation message

crocodile.cpp: In function 'void dfs(int, int)':
crocodile.cpp:30:26: warning: unused variable 'e' [-Wunused-variable]
   30 |         int u = k.first, e = k.second;
      |                          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 55128 KB Output is correct
2 Correct 23 ms 55104 KB Output is correct
3 Correct 26 ms 55124 KB Output is correct
4 Correct 25 ms 55124 KB Output is correct
5 Correct 26 ms 55116 KB Output is correct
6 Correct 27 ms 55164 KB Output is correct
7 Correct 28 ms 55248 KB Output is correct
8 Correct 26 ms 55216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 55128 KB Output is correct
2 Correct 23 ms 55104 KB Output is correct
3 Correct 26 ms 55124 KB Output is correct
4 Correct 25 ms 55124 KB Output is correct
5 Correct 26 ms 55116 KB Output is correct
6 Correct 27 ms 55164 KB Output is correct
7 Correct 28 ms 55248 KB Output is correct
8 Correct 26 ms 55216 KB Output is correct
9 Incorrect 28 ms 55380 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 55128 KB Output is correct
2 Correct 23 ms 55104 KB Output is correct
3 Correct 26 ms 55124 KB Output is correct
4 Correct 25 ms 55124 KB Output is correct
5 Correct 26 ms 55116 KB Output is correct
6 Correct 27 ms 55164 KB Output is correct
7 Correct 28 ms 55248 KB Output is correct
8 Correct 26 ms 55216 KB Output is correct
9 Incorrect 28 ms 55380 KB Output isn't correct
10 Halted 0 ms 0 KB -