답안 #395266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
395266 2021-04-28T04:22:56 Z suren 자매 도시 (APIO20_swap) C++14
0 / 100
2000 ms 13028 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define F first
#define S second
int n, m, flag = true;
vector < int > u, v, w;
vector < int > vc[100045];
pair < int , pair< int, int > > p[200045];
int parent[100045];
int sz[100045];
int get( ll x ){
	if( parent[x] == x )
		return x;
	return parent[x] = get( parent[x] );
}
void init(int N, int M,
          std::vector<int> U, std::vector<int> V, std::vector<int> W) {
		int i;
		n = N;m = M;u = U;v = V;w = W;
		for( i = 0; i < m; i ++ ){
			p[i].second.F=u[i];
			p[i].second.S=v[i];
			p[i].first=w[i];
		}
		sort( p, p + m );
}
int getMinimumFuelCapacity(int X, int Y) {
	map < int, int > mp;
	int i;
	flag = false;
	mp.clear();
	for( i = 1; i <= n; i ++ ){
			parent[i] = i; 
	}
	for( i = 0; i < n; i ++ )
		vc[i].clear();
	for( i = 0; i < m; i ++ ){
		int x = get( p[i].second.F );
		int y = get( p[i].second.S );
		if( x != y ){
			if( y > x ){
				swap(y, x);
			} 
			parent[y] = x;
		}
		int parx = get( X );
		int pary = get( Y );
		mp[ p[i].S.F ] = 1;
		mp[ p[i].S.S ] = 1;
		if( parx != pary )
			continue;
		if( mp.size() == i+2 )
			continue;
		return p[i].F;
	}
	return -1;
}

Compilation message

swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:55:17: warning: comparison of integer expressions of different signedness: 'std::map<int, int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   55 |   if( mp.size() == i+2 )
      |       ~~~~~~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Incorrect 3 ms 2636 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Execution timed out 2068 ms 13028 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Incorrect 3 ms 2636 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Incorrect 3 ms 2636 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Incorrect 3 ms 2636 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Incorrect 3 ms 2636 KB Output isn't correct
5 Halted 0 ms 0 KB -