답안 #966944

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
966944 2024-04-20T16:46:21 Z Hugo1729 악어의 지하 도시 (IOI11_crocodile) C++11
46 / 100
187 ms 262144 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
// typedef long long ll;

int dp[100001]={0};
int n,m,k;
vector<pair<int,int>> adj[1000001];
bool blocked[100001]={0};

void dfs(int v, int pV){
    if(blocked[v])dp[v]=0;
    else{
        vector<int> sus(3,1000000001);

        for(auto [w,d] : adj[v]){
            if(w!=pV){
                dfs(w,v);
                sus[2]=dp[w]+d;
                sort(sus.begin(),sus.end());
            }
        }
        dp[v]=min(1000000001,sus[1]);
    }
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    n=N;
    m=M;
    k=K;

    for(int i=0;i<m;i++){
        adj[R[i][0]].push_back({R[i][1],L[i]});
        adj[R[i][1]].push_back({R[i][0],L[i]});
    }

    for(int i=0;i<k;i++)blocked[P[i]]=1;

    dfs(0,0);

    // for(int i=0;i<n;i++)cout << dp[i] << ' ';
    // cout << '\n';

    return dp[0];
}


Compilation message

crocodile.cpp: In function 'void dfs(int, int)':
crocodile.cpp:16:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   16 |         for(auto [w,d] : adj[v]){
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 26968 KB Output is correct
2 Correct 7 ms 26972 KB Output is correct
3 Correct 7 ms 27172 KB Output is correct
4 Correct 6 ms 27228 KB Output is correct
5 Correct 6 ms 27180 KB Output is correct
6 Correct 6 ms 27224 KB Output is correct
7 Correct 9 ms 27228 KB Output is correct
8 Correct 8 ms 27200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 26968 KB Output is correct
2 Correct 7 ms 26972 KB Output is correct
3 Correct 7 ms 27172 KB Output is correct
4 Correct 6 ms 27228 KB Output is correct
5 Correct 6 ms 27180 KB Output is correct
6 Correct 6 ms 27224 KB Output is correct
7 Correct 9 ms 27228 KB Output is correct
8 Correct 8 ms 27200 KB Output is correct
9 Runtime error 187 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 26968 KB Output is correct
2 Correct 7 ms 26972 KB Output is correct
3 Correct 7 ms 27172 KB Output is correct
4 Correct 6 ms 27228 KB Output is correct
5 Correct 6 ms 27180 KB Output is correct
6 Correct 6 ms 27224 KB Output is correct
7 Correct 9 ms 27228 KB Output is correct
8 Correct 8 ms 27200 KB Output is correct
9 Runtime error 187 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -