답안 #91252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91252 2018-12-26T17:31:30 Z arman_ferdous 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
227 ms 263168 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 1e5+10;

int n, isExit[N];
vector< pair<int,int> > g[N];

ll ans[N][2];
void solve(int u, int f) {
	if(isExit[u]) return;

	ans[u][0] = ans[u][1] = (ll)1e18;
	for(auto e : g[u]) if(e.first != f) {
		solve(e.first, u);
		ll C = e.second + ans[e.first][1];
		if(C < ans[u][0]) { swap(ans[u][0], ans[u][1]); ans[u][0] = C; }
		else if(C < ans[u][1]) ans[u][1] = C;
	}
}

int travel_plan(int N_, int M, int R[][2], int L[], int K, int P[]) {
	n = N_;
	for(int i = 0; i < M; i++) {
		g[R[i][0]].push_back({R[i][1], L[i]});
		g[R[i][1]].push_back({R[i][0], L[i]});
	}
	for(int i = 0; i < K; i++)
		isExit[P[i]] = 1;
	solve(0,-1);
	return ans[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2636 KB Output is correct
2 Correct 4 ms 2812 KB Output is correct
3 Correct 4 ms 2932 KB Output is correct
4 Correct 3 ms 2932 KB Output is correct
5 Correct 4 ms 3040 KB Output is correct
6 Correct 4 ms 3152 KB Output is correct
7 Correct 4 ms 3152 KB Output is correct
8 Correct 5 ms 3424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2636 KB Output is correct
2 Correct 4 ms 2812 KB Output is correct
3 Correct 4 ms 2932 KB Output is correct
4 Correct 3 ms 2932 KB Output is correct
5 Correct 4 ms 3040 KB Output is correct
6 Correct 4 ms 3152 KB Output is correct
7 Correct 4 ms 3152 KB Output is correct
8 Correct 5 ms 3424 KB Output is correct
9 Runtime error 227 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2636 KB Output is correct
2 Correct 4 ms 2812 KB Output is correct
3 Correct 4 ms 2932 KB Output is correct
4 Correct 3 ms 2932 KB Output is correct
5 Correct 4 ms 3040 KB Output is correct
6 Correct 4 ms 3152 KB Output is correct
7 Correct 4 ms 3152 KB Output is correct
8 Correct 5 ms 3424 KB Output is correct
9 Runtime error 227 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -