답안 #234721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
234721 2020-05-25T10:52:35 Z Dilshod_Imomov 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
12 ms 896 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

const int NN = 1e3 + 7;

vector < pair < int, int > > adj[NN];
int dp[NN], l[NN];

void dfs( int v, int p ) {
	int mn1 = 1e9, mn2 = 1e9;
	// cout << "-> " << v << ' ' << p << '\n';
	for ( auto pr: adj[v] ) {
		int u = pr.first, ind = pr.second;
		if ( u != p ) {
			dfs( u, v );
			int cnt = dp[u] + l[ind];
			if ( cnt <= mn1 ) {
				mn2 = mn1;
				mn1 = cnt;
			}
			else if ( cnt < mn2 ) {
				mn2 = cnt;
			}
		}
	}
	if ( mn2 == 1e9 ) {
		mn2 = mn1;
	}
	if ( mn2 == 1e9 ) {
		mn2 = 0;
	}
	// cout << "-> " << v << ' ' << p << ' ' << mn1 << ' ' << mn2 << '\n';
	dp[v] = mn2;
}

int travel_plan(int n, int m, int R[][2], int L[], int K, int P[])
{
	for ( int i = 0; i < m; i++ ) {
		int u = R[i][0], v = R[i][1];
		adj[u].push_back( { v, i } );
		adj[v].push_back( { u, i } );
		l[i] = L[i];
	}
	dfs( 0, 0 );
	return dp[0];
}

# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Runtime error 12 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Runtime error 12 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -