답안 #757125

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757125 2023-06-12T16:53:02 Z CpDark 악어의 지하 도시 (IOI11_crocodile) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#include "crocodile.h"


using namespace std;
typedef long long ll;
typedef pair<int, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<bool> vb;
typedef vector<vb> vvb;

vvp graph;
vi isOut;

ll dfs(int v, int p) {
    if (isOut[v])return 0;
    ll best1 = 0;
    ll best2 = 0;
    for (int i = 0;i < graph[v].size();i++) {
        int u = graph[v][i].first;
        ll w = graph[v][i].second;
        if (u != p) {
            ll curr = dfs(u, v) + w;

            if (curr <= best1) {
                if (best1 < best2) best2 = best1;
                best1 = curr;
            }
            else if (curr < best2) best2 = curr;
        }
    }
    return best2;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){

    graph.resize(N);
    isOut.resize(N);
    for (int i = 0;i < M;i++) {
        graph[R[i][0]].push_back({ R[i][1], L[i] });
        graph[R[i][1]].push_back({ R[i][0], L[i] });
    }

    for (int i = 0;i < K;i++) {
        isOut[P[i]] = true;
    }

    int ans = (int)dfs(0, 0);
    return ans;
}

Compilation message

crocodile.cpp: In function 'll dfs(int, int)':
crocodile.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i = 0;i < graph[v].size();i++) {
      |                    ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -