답안 #649389

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



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

void dfs(int v, int p){
    if(is[v]){
        return;
    }
    vector<ll> dist;
    vis[v] = 1;
    dp[0][v] = dp[1][v] = MOD;
    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[1][u] + e);
    }
    sort(dist.begin(), dist.end());
    // cout << '\n';
    // cout << v << ' ';
    // for(int x: dist) cout << x << ' ';
    dp[0][v] = dist[0];
    if(dist.size() == 1) dp[1][v] = MOD;
    else dp[1][v] = dist[1];
    // cout << dp[0][v] << ' ' << dp[1][v] << ' ' << v << '\n';
}

int travel_plan(int F, int M, int R[][2], int L[], int K, int P[]){ 
    n = F;
    m = M;
    dp[0].resize(n);
    dp[1].resize(n);
    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[1][0];
}

Compilation message

crocodile.cpp:5:30: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    5 | const int X = 1e6, MOD = 1e18+7;
      |                          ~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23836 KB Output is correct
4 Correct 15 ms 23792 KB Output is correct
5 Correct 12 ms 23892 KB Output is correct
6 Correct 13 ms 23892 KB Output is correct
7 Correct 13 ms 23948 KB Output is correct
8 Correct 12 ms 23968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23836 KB Output is correct
4 Correct 15 ms 23792 KB Output is correct
5 Correct 12 ms 23892 KB Output is correct
6 Correct 13 ms 23892 KB Output is correct
7 Correct 13 ms 23948 KB Output is correct
8 Correct 12 ms 23968 KB Output is correct
9 Correct 16 ms 24148 KB Output is correct
10 Incorrect 14 ms 23852 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23836 KB Output is correct
4 Correct 15 ms 23792 KB Output is correct
5 Correct 12 ms 23892 KB Output is correct
6 Correct 13 ms 23892 KB Output is correct
7 Correct 13 ms 23948 KB Output is correct
8 Correct 12 ms 23968 KB Output is correct
9 Correct 16 ms 24148 KB Output is correct
10 Incorrect 14 ms 23852 KB Output isn't correct
11 Halted 0 ms 0 KB -