답안 #1046348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1046348 2024-08-06T13:20:19 Z xnqs Cheap flights (LMIO18_pigus_skrydziai) C++17
28 / 100
3000 ms 53336 KB
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <set>
 
int gs, edg;
std::vector<std::set<std::pair<int,int>>> adj_list;
std::vector<std::tuple<int,int,int>> edges;

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
 
	std::cin >> gs >> edg;
	adj_list.resize(gs+1);
 
	for (int i = 0, a, b, c; i < edg; i++) {
		std::cin >> a >> b >> c;
		adj_list[a].emplace(b,c);
		adj_list[b].emplace(a,c);
		edges.emplace_back(a,b,c);
	}
 
	// try all star graphs
	int64_t ans = 0;
	for (int i = 1; i <= gs; i++) {
		int64_t cand = 0;
		for (const auto& [j, w] : adj_list[i]) {
			cand += w;
		}
		ans = std::max(ans,cand);
	}
 
	// try all "triangle" cycles
	for (const auto& [a, b, c] : edges) {
		int x = a;
		int y = b;
		
		if (adj_list[x].size()>adj_list[y].size()) {
			std::swap(x,y);
		}

		for (const auto& [i, w] : adj_list[x]) {
			auto it = adj_list[y].lower_bound(std::pair<int,int>(i,0));
			if (it!=adj_list[y].end()&&it->first==i) {
				ans = std::max(ans,(int64_t)c+w+it->second);
			}
		}
	}
 
	std::cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 54 ms 2456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 54 ms 2456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Execution timed out 3070 ms 53336 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 30472 KB Output is correct
2 Correct 157 ms 46236 KB Output is correct
3 Correct 30 ms 15632 KB Output is correct
4 Correct 75 ms 30468 KB Output is correct
5 Correct 206 ms 42748 KB Output is correct
6 Correct 979 ms 13576 KB Output is correct
7 Correct 52 ms 39592 KB Output is correct
8 Correct 62 ms 47104 KB Output is correct
9 Correct 3 ms 14424 KB Output is correct
10 Correct 985 ms 13576 KB Output is correct
11 Correct 101 ms 40448 KB Output is correct
12 Correct 1474 ms 26724 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 593 ms 10968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 30472 KB Output is correct
2 Correct 157 ms 46236 KB Output is correct
3 Correct 30 ms 15632 KB Output is correct
4 Correct 75 ms 30468 KB Output is correct
5 Correct 206 ms 42748 KB Output is correct
6 Correct 979 ms 13576 KB Output is correct
7 Correct 52 ms 39592 KB Output is correct
8 Correct 62 ms 47104 KB Output is correct
9 Correct 3 ms 14424 KB Output is correct
10 Correct 985 ms 13576 KB Output is correct
11 Correct 101 ms 40448 KB Output is correct
12 Correct 1474 ms 26724 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 593 ms 10968 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 54 ms 2456 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Execution timed out 3070 ms 53336 KB Time limit exceeded
37 Halted 0 ms 0 KB -