답안 #1042348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1042348 2024-08-02T22:14:06 Z allin27x 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
2 ms 8796 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 1e5+4;
const int INF = 1e9+2;
vector<pair<int,int>> adj[N];
int vis[N];
int ex[N];
int ans[N];

int dfs(int i){
	// cout<<i<<'\n';
	vis[i] = 1;
	if (ex[i]) return 0;
	int b1=INF, b2=INF;
	for (auto [c,w]: adj[i]){
		if (vis[c] && ans[c] == -1) continue;
		int v = (vis[c])? w + ans[c] : w + dfs(c);
		if (v<b1) b2=b1, b1=v;
		else if (v<b2) b2=v;
	}
	// cout<<i<<' '<<b1<<' '<<b2<<'\n';
	ans[i] = b2;
	return b2;
}

signed travel_plan(signed n, signed m, signed r[][2], signed l[], signed k, signed p[]){
	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<n; i++) ans[i] = -1;
	for (int i=0; i<k; i++) ex[p[i]] = 1, ans[p[i]] = 0;

	return (signed)dfs(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8796 KB Output is correct
10 Incorrect 1 ms 8540 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8796 KB Output is correct
10 Incorrect 1 ms 8540 KB Output isn't correct
11 Halted 0 ms 0 KB -