Submission #906473

# Submission time Handle Problem Language Result Execution time Memory
906473 2024-01-14T10:46:14 Z pcc Cheap flights (LMIO18_pigus_skrydziai) C++14
28 / 100
2848 ms 119896 KB
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt")

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>


const int mxn = 3e5+10;
const int lim = 2.6*CLOCKS_PER_SEC;
int N,M;
cc_hash_table<int,ll> mp[mxn];
vector<tlll> edges;
ll sum[mxn];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int st = clock();
	cin>>N>>M;
	for(int i = 0;i<M;i++){
		int a,b,c;
		cin>>a>>b>>c;
		mp[a][b] = c;
		mp[b][a] = c;
		sum[a] += c;
		sum[b] += c;
		edges.push_back(make_tuple(a,b,c));
	}
	srand(time(NULL));
	random_shuffle(edges.begin(),edges.end());
	ll ans = *max_element(sum,sum+N+1);
	for(auto &i:edges){
		int a = get<0>(i),b = get<1>(i),ts = get<2>(i);
		if(mp[a].size()>mp[b].size())swap(a,b);
		for(auto &j:mp[a]){
			if(clock()-st>=lim)break;
			if(mp[b].find(j.fs) != mp[b].end()){
				ans = max(ans,mp[b][j.fs]+j.sc+ts);
			}
		}
		if(clock()-st>=lim)break;
	}
	cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 37 ms 54352 KB Output is correct
2 Correct 35 ms 54364 KB Output is correct
3 Correct 34 ms 54356 KB Output is correct
4 Correct 33 ms 54360 KB Output is correct
5 Correct 33 ms 54588 KB Output is correct
6 Correct 1343 ms 57316 KB Output is correct
7 Correct 33 ms 54364 KB Output is correct
8 Correct 32 ms 54356 KB Output is correct
9 Correct 40 ms 54376 KB Output is correct
10 Correct 35 ms 54364 KB Output is correct
11 Correct 36 ms 54612 KB Output is correct
12 Correct 38 ms 54624 KB Output is correct
13 Correct 34 ms 54356 KB Output is correct
14 Correct 38 ms 54360 KB Output is correct
15 Correct 40 ms 54352 KB Output is correct
16 Correct 38 ms 54412 KB Output is correct
17 Correct 34 ms 54352 KB Output is correct
18 Correct 41 ms 54768 KB Output is correct
19 Correct 50 ms 54848 KB Output is correct
20 Correct 39 ms 54364 KB Output is correct
21 Correct 35 ms 54356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 54352 KB Output is correct
2 Correct 35 ms 54364 KB Output is correct
3 Correct 34 ms 54356 KB Output is correct
4 Correct 33 ms 54360 KB Output is correct
5 Correct 33 ms 54588 KB Output is correct
6 Correct 1343 ms 57316 KB Output is correct
7 Correct 33 ms 54364 KB Output is correct
8 Correct 32 ms 54356 KB Output is correct
9 Correct 40 ms 54376 KB Output is correct
10 Correct 35 ms 54364 KB Output is correct
11 Correct 36 ms 54612 KB Output is correct
12 Correct 38 ms 54624 KB Output is correct
13 Correct 34 ms 54356 KB Output is correct
14 Correct 38 ms 54360 KB Output is correct
15 Correct 40 ms 54352 KB Output is correct
16 Correct 38 ms 54412 KB Output is correct
17 Correct 34 ms 54352 KB Output is correct
18 Correct 41 ms 54768 KB Output is correct
19 Correct 50 ms 54848 KB Output is correct
20 Correct 39 ms 54364 KB Output is correct
21 Correct 35 ms 54356 KB Output is correct
22 Correct 2848 ms 117564 KB Output is correct
23 Correct 2673 ms 113508 KB Output is correct
24 Correct 323 ms 57352 KB Output is correct
25 Correct 68 ms 55260 KB Output is correct
26 Correct 62 ms 55200 KB Output is correct
27 Correct 44 ms 54736 KB Output is correct
28 Correct 2683 ms 79876 KB Output is correct
29 Correct 2649 ms 65028 KB Output is correct
30 Correct 2658 ms 69304 KB Output is correct
31 Correct 43 ms 54680 KB Output is correct
32 Correct 35 ms 54612 KB Output is correct
33 Correct 2742 ms 119896 KB Output is correct
34 Incorrect 2735 ms 116252 KB Output isn't correct
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 409 ms 71716 KB Output is correct
2 Correct 909 ms 86112 KB Output is correct
3 Correct 269 ms 65184 KB Output is correct
4 Correct 562 ms 74140 KB Output is correct
5 Correct 1450 ms 91220 KB Output is correct
6 Correct 2648 ms 69124 KB Output is correct
7 Correct 516 ms 78840 KB Output is correct
8 Correct 656 ms 87280 KB Output is correct
9 Correct 37 ms 56664 KB Output is correct
10 Correct 2647 ms 69124 KB Output is correct
11 Correct 646 ms 93188 KB Output is correct
12 Correct 2667 ms 84016 KB Output is correct
13 Correct 33 ms 54352 KB Output is correct
14 Correct 2654 ms 67844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 409 ms 71716 KB Output is correct
2 Correct 909 ms 86112 KB Output is correct
3 Correct 269 ms 65184 KB Output is correct
4 Correct 562 ms 74140 KB Output is correct
5 Correct 1450 ms 91220 KB Output is correct
6 Correct 2648 ms 69124 KB Output is correct
7 Correct 516 ms 78840 KB Output is correct
8 Correct 656 ms 87280 KB Output is correct
9 Correct 37 ms 56664 KB Output is correct
10 Correct 2647 ms 69124 KB Output is correct
11 Correct 646 ms 93188 KB Output is correct
12 Correct 2667 ms 84016 KB Output is correct
13 Correct 33 ms 54352 KB Output is correct
14 Correct 2654 ms 67844 KB Output is correct
15 Correct 37 ms 54352 KB Output is correct
16 Correct 35 ms 54364 KB Output is correct
17 Correct 34 ms 54356 KB Output is correct
18 Correct 33 ms 54360 KB Output is correct
19 Correct 33 ms 54588 KB Output is correct
20 Correct 1343 ms 57316 KB Output is correct
21 Correct 33 ms 54364 KB Output is correct
22 Correct 32 ms 54356 KB Output is correct
23 Correct 40 ms 54376 KB Output is correct
24 Correct 35 ms 54364 KB Output is correct
25 Correct 36 ms 54612 KB Output is correct
26 Correct 38 ms 54624 KB Output is correct
27 Correct 34 ms 54356 KB Output is correct
28 Correct 38 ms 54360 KB Output is correct
29 Correct 40 ms 54352 KB Output is correct
30 Correct 38 ms 54412 KB Output is correct
31 Correct 34 ms 54352 KB Output is correct
32 Correct 41 ms 54768 KB Output is correct
33 Correct 50 ms 54848 KB Output is correct
34 Correct 39 ms 54364 KB Output is correct
35 Correct 35 ms 54356 KB Output is correct
36 Correct 2848 ms 117564 KB Output is correct
37 Correct 2673 ms 113508 KB Output is correct
38 Correct 323 ms 57352 KB Output is correct
39 Correct 68 ms 55260 KB Output is correct
40 Correct 62 ms 55200 KB Output is correct
41 Correct 44 ms 54736 KB Output is correct
42 Correct 2683 ms 79876 KB Output is correct
43 Correct 2649 ms 65028 KB Output is correct
44 Correct 2658 ms 69304 KB Output is correct
45 Correct 43 ms 54680 KB Output is correct
46 Correct 35 ms 54612 KB Output is correct
47 Correct 2742 ms 119896 KB Output is correct
48 Incorrect 2735 ms 116252 KB Output isn't correct
49 Halted 0 ms 0 KB -