답안 #783572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783572 2023-07-15T04:20:25 Z Sir_Ahmed_Imran 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
3 ms 3056 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define MAXN 100001
ll dp[MAXN];
bool x[MAXN];
bool v[MAXN];
vector<pair<int,ll>> a[MAXN];
void dfs(int n,int m){
	v[n]=1;
	if(x[n])
		return;
	ll p=1e9+7;
	ll q=1e9+7;
	for(auto& i:a[n]){
		if(i.ff==m) 
			continue;
		if(!v[i.ff])
			dfs(i.ff,n);
		if(dp[i.ff]+i.ss<p){
			q=p;
			p=dp[i.ff]+i.ss;
		}
		else q=min(q,dp[i.ff]+i.ss);
	}
	dp[n]=q;
}
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]){
	for(int i=0;i<n;i++){
		a[i]={};
		v[i]=x[i]=0;
		dp[i]=1e9+7;
	}
	for(int i=0;i<m;i++){
		a[R[i][0]].push_back({R[i][1],L[i]});
		a[R[i][1]].push_back({R[i][0],L[i]});
	}
	for(int i=0;i<k;i++){
		x[P[i]]=1;
		dp[P[i]]=0;
	}
	dfs(0,-1);
	return dp[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 3 ms 3056 KB Output is correct
10 Incorrect 2 ms 2664 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 3 ms 3056 KB Output is correct
10 Incorrect 2 ms 2664 KB Output isn't correct
11 Halted 0 ms 0 KB -