답안 #783568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783568 2023-07-15T04:17:24 Z Sir_Ahmed_Imran 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
3 ms 3060 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]=dp[i]=0;
	}
	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;
	dfs(0,-1);
	return dp[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:33:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   33 |   v[i]=x[i]=dp[i]=0;
      |             ~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2660 KB Output is correct
3 Correct 2 ms 2604 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2668 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 2800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2660 KB Output is correct
3 Correct 2 ms 2604 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2668 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 2800 KB Output is correct
9 Incorrect 3 ms 3060 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2660 KB Output is correct
3 Correct 2 ms 2604 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2668 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 2800 KB Output is correct
9 Incorrect 3 ms 3060 KB Output isn't correct
10 Halted 0 ms 0 KB -