Submission #783560

# Submission time Handle Problem Language Result Execution time Memory
783560 2023-07-15T03:54:59 Z Sir_Ahmed_Imran Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
2 ms 2644 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){
	v[n]=1;
	if(x[n])
		return;
	ll p=1e9+7,q=p;
	for(auto& i:a[n]){
		if(!v[i.ff])
			dfs(i.ff);
		if(dp[i.ff]+i.ss<p){
			q=p;
			p=dp[i.ff]+i.ss;
		}
		else q=min(p,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]]=0;
	dfs(0);
	return dp[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:30:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   30 |   v[i]=x[i]=dp[i]=0;
      |             ~~~~~^~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -