답안 #394715

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394715 2021-04-27T08:23:53 Z suren 자매 도시 (APIO20_swap) C++14
0 / 100
1 ms 460 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
int n, m;
vector < int > u, v, w;
vector < int > vc[1045];
void init(int N, int M,
          std::vector<int> U, std::vector<int> V, std::vector<int> W) {
		u = U;
		v = V;
		w = W;
}
bool vis[1045];
int getMinimumFuelCapacity(int X, int Y) {
	ll flag = true, i;
	map < pair < int , int >, int > mp;
	for( i = 0; i < m; i ++ ){
		vc[ u[i] ].pb( v[i] );
		vc[ v[i] ].pb( u[i] );
		mp[ mk( u[i], v[i] ) ] = w[i];
		mp[ mk( v[i], u[i] ) ] = w[i];
	}
	for( i = 0; i < n; i ++ ){
		if( vc[i].size() != 2 ){
			flag = false;
			break;
		}
	}
	if( flag == true ){
		vis[X] = 1;
		int p = vc[X][0];
		int ans = mp[ mk(X,p) ];
		while( p != Y ){
			vis[ p ] = 1;
			if( vc[p][0] == 0 ){
				ans = max( ans, mp[ mk( p, vc[p][0] ) ] );
				p = vc[p][0];
			}
			else{
				ans = max( ans, mp[ mk( p, vc[p][1] ) ] );
				p = vc[p][1];
			}
		}
		p = vc[X][1];
		int ans1 = mp[ mk(X,p) ];
		while( p != Y ){
			vis[ p ] = 1;
			if( vc[p][0] == 0 ){
				ans1 = max( ans, mp[ mk( p, vc[p][0] ) ] );
				p = vc[p][0];
			}
			else{
				ans1 = max( ans, mp[ mk( p, vc[p][1] ) ] );
				p = vc[p][1];
			}
		}
		return min( ans, ans1 );
	}
	flag = true;
	int ans = 0;
	for( i = 0; i < n; i ++ ){
		
		if( vc[i].size() >= 3 ){
			flag = false;
			break;
		}
		
	}
	if( flag == true ){
		for( i = 0; i < m; i ++ )
			ans = max( ans, w[i] );
		return ans;
	}
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -