답안 #569902

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
569902 2022-05-28T05:32:41 Z sumit_kk10 자매 도시 (APIO20_swap) C++17
13 / 100
244 ms 37568 KB
#include "swap.h"
#include<bits/stdc++.h>
#include <vector>
#define pb push_back
using namespace std;
const int N = 1e6 + 5;
vector<pair<int, int> > g[N];
int mx, n, m;
bool sb2 = 1, sb1 = 1;
 
void init(int N, int M,
          std::vector<int> U, std::vector<int> V, std::vector<int> W) {
	n = N;
	m = M;
	int wut = 0;
	map<int, int> mp;
	for(int i = 0; i < M; ++i){
		int u = U[i], v = V[i], w = W[i];
		if(u != 0 and v != 0)
			sb2 = false;
		g[u].pb({w, v});
		g[v].pb({w, u});
		mx = max(mx, w);
		mp[u]++;
		mp[v]++;
	}
	for(int i = 0; i < n; ++i)
		sort(g[i].begin(), g[i].end());
	for(auto k : mp)
		wut = max(wut, k.second);
	if(wut > 2)
		sb1 = false;
}
 
int getMinimumFuelCapacity(int X, int Y) {
	if(sb2 and m == n - 1){
		if(n <= 3) return -1;
		if(X == 0){
			int x = g[Y][0].first, xx, dest, mn;
			if(g[0][0].second != Y){
				xx = g[0][0].first;
				dest = g[0][0].second;
			}else{
				xx = g[0][1].first;
				dest = g[0][1].second;
			}
			if(g[0][1].second != Y and g[0][1].second != dest)
				mn = g[0][1].first;
			else
				mn = g[0][2].first;
			return max({x, xx, mn});
		}
		int x = g[X][0].first, xx = g[Y][0].first, mn;
		if(g[0][0].second != X and g[0][0].second != Y)
			mn = g[0][0].first;
		else if(g[0][1].second != X and g[0][1].second != Y)
			mn = g[0][1].first;
		else
			mn = g[0][2].first;
		return max({x, xx, mn});
	}
	if(sb1){
		if(m == n - 1)
			return -1;
		else
			return mx;
	}
}

Compilation message

swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:68:1: warning: control reaches end of non-void function [-Wreturn-type]
   68 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23788 KB Output is correct
3 Correct 13 ms 23796 KB Output is correct
4 Correct 13 ms 23780 KB Output is correct
5 Correct 13 ms 23876 KB Output is correct
6 Correct 14 ms 23764 KB Output is correct
7 Correct 13 ms 23816 KB Output is correct
8 Correct 14 ms 23884 KB Output is correct
9 Correct 137 ms 31652 KB Output is correct
10 Correct 168 ms 33480 KB Output is correct
11 Correct 192 ms 33380 KB Output is correct
12 Correct 176 ms 33956 KB Output is correct
13 Correct 194 ms 33848 KB Output is correct
14 Correct 132 ms 31812 KB Output is correct
15 Correct 216 ms 35416 KB Output is correct
16 Correct 228 ms 35172 KB Output is correct
17 Correct 234 ms 35636 KB Output is correct
18 Correct 196 ms 35696 KB Output is correct
19 Correct 82 ms 28868 KB Output is correct
20 Correct 244 ms 36496 KB Output is correct
21 Correct 189 ms 36512 KB Output is correct
22 Correct 244 ms 37084 KB Output is correct
23 Correct 214 ms 37180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23788 KB Output is correct
3 Correct 161 ms 37160 KB Output is correct
4 Correct 172 ms 37556 KB Output is correct
5 Correct 187 ms 37460 KB Output is correct
6 Correct 203 ms 37408 KB Output is correct
7 Correct 173 ms 37568 KB Output is correct
8 Correct 184 ms 37076 KB Output is correct
9 Correct 240 ms 37348 KB Output is correct
10 Correct 164 ms 36988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23788 KB Output is correct
3 Correct 13 ms 23796 KB Output is correct
4 Correct 13 ms 23780 KB Output is correct
5 Correct 13 ms 23876 KB Output is correct
6 Correct 14 ms 23764 KB Output is correct
7 Correct 13 ms 23816 KB Output is correct
8 Correct 14 ms 23884 KB Output is correct
9 Incorrect 13 ms 23764 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 23764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23788 KB Output is correct
3 Correct 13 ms 23796 KB Output is correct
4 Correct 13 ms 23780 KB Output is correct
5 Correct 13 ms 23876 KB Output is correct
6 Correct 14 ms 23764 KB Output is correct
7 Correct 13 ms 23816 KB Output is correct
8 Correct 14 ms 23884 KB Output is correct
9 Correct 137 ms 31652 KB Output is correct
10 Correct 168 ms 33480 KB Output is correct
11 Correct 192 ms 33380 KB Output is correct
12 Correct 176 ms 33956 KB Output is correct
13 Correct 194 ms 33848 KB Output is correct
14 Correct 132 ms 31812 KB Output is correct
15 Correct 216 ms 35416 KB Output is correct
16 Correct 228 ms 35172 KB Output is correct
17 Correct 234 ms 35636 KB Output is correct
18 Correct 196 ms 35696 KB Output is correct
19 Correct 161 ms 37160 KB Output is correct
20 Correct 172 ms 37556 KB Output is correct
21 Correct 187 ms 37460 KB Output is correct
22 Correct 203 ms 37408 KB Output is correct
23 Correct 173 ms 37568 KB Output is correct
24 Correct 184 ms 37076 KB Output is correct
25 Correct 240 ms 37348 KB Output is correct
26 Correct 164 ms 36988 KB Output is correct
27 Incorrect 12 ms 23764 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 23764 KB Output isn't correct
2 Halted 0 ms 0 KB -