Submission #499115

# Submission time Handle Problem Language Result Execution time Memory
499115 2021-12-27T08:52:36 Z Kipras Cheap flights (LMIO18_pigus_skrydziai) C++14
53 / 100
2504 ms 75488 KB
#include <bits/stdc++.h>
#define debug cout << "alio\n"
#define pb push_back
#define ll long long
#define MAX (int)3e5
using namespace std;

vector<int> adj[MAX];
map<pair<int, int>, int> pe;

int main()
{
	int N, M;
	cin >> N >> M;
	for(int i = 0; i < M; i++)
	{
		int a, b;
		ll p;
		cin >> a >> b >> p;
		adj[a-1].pb(b-1);
		adj[b-1].pb(a-1);
		pe[{a-1, b-1}] = p;
		pe[{b-1, a-1}] = p;
	}
	ll mx = -1;
	for(int i = 0; i < N; i++)
	{
		if(adj[i].empty())
			continue;
		ll sum_tr = 0;
		ll sum_zv = 0;
		// perrenkam zvaigzdes
		for(int sidx : adj[i])
		{
			sum_zv += pe[{i, sidx}];
		}
		// perrenkam trikampius
		//cout << i << "-tojo miesto kaimynai:\n";
		for(int j = 0; j < (int)(adj[i].size())-1; j++) // gali pasirodyt, kad kils gresme jeigu yra tik du miestai, kuriuos jungia 1 briauna, bet td jie po zvaigzdute palenda ir juos vstk isrenka, net nereikia sito ciklo
		{
			int kaim1 = adj[i][j];
			int kaim2 = adj[i][j+1];
			/*
			cout << kaim1 << ' ' << miestai[i].pelnas[kaim1] << '\n';
			cout << kaim2 << ' ' << miestai[i].pelnas[kaim2] << '\n';
			cout << "Tarpusavy " << miestai[kaim1].pelnas[kaim2] << '\n';
			*/
			if(pe.find({kaim1, kaim2}) != pe.end()) // jeigu i-tojo miesto kaimynai j ir j+1 irgi turi kelia, tai susidaro trikampis
				sum_tr = pe[{kaim1, kaim2}] + pe[{i, kaim1}] + pe[{i, kaim2}];
			//cout << '\n';
		}
		if(sum_zv > mx) mx = sum_zv;
		if(sum_tr > mx) mx = sum_tr;
	}
	cout << mx << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7244 KB Output is correct
2 Correct 4 ms 7244 KB Output is correct
3 Correct 4 ms 7244 KB Output is correct
4 Correct 4 ms 7244 KB Output is correct
5 Correct 4 ms 7244 KB Output is correct
6 Correct 38 ms 9968 KB Output is correct
7 Correct 4 ms 7244 KB Output is correct
8 Correct 3 ms 7244 KB Output is correct
9 Correct 4 ms 7244 KB Output is correct
10 Correct 4 ms 7244 KB Output is correct
11 Correct 4 ms 7372 KB Output is correct
12 Correct 6 ms 7372 KB Output is correct
13 Correct 4 ms 7244 KB Output is correct
14 Correct 3 ms 7244 KB Output is correct
15 Correct 4 ms 7244 KB Output is correct
16 Correct 4 ms 7244 KB Output is correct
17 Correct 5 ms 7244 KB Output is correct
18 Correct 5 ms 7412 KB Output is correct
19 Correct 7 ms 7628 KB Output is correct
20 Correct 3 ms 7244 KB Output is correct
21 Correct 4 ms 7244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7244 KB Output is correct
2 Correct 4 ms 7244 KB Output is correct
3 Correct 4 ms 7244 KB Output is correct
4 Correct 4 ms 7244 KB Output is correct
5 Correct 4 ms 7244 KB Output is correct
6 Correct 38 ms 9968 KB Output is correct
7 Correct 4 ms 7244 KB Output is correct
8 Correct 3 ms 7244 KB Output is correct
9 Correct 4 ms 7244 KB Output is correct
10 Correct 4 ms 7244 KB Output is correct
11 Correct 4 ms 7372 KB Output is correct
12 Correct 6 ms 7372 KB Output is correct
13 Correct 4 ms 7244 KB Output is correct
14 Correct 3 ms 7244 KB Output is correct
15 Correct 4 ms 7244 KB Output is correct
16 Correct 4 ms 7244 KB Output is correct
17 Correct 5 ms 7244 KB Output is correct
18 Correct 5 ms 7412 KB Output is correct
19 Correct 7 ms 7628 KB Output is correct
20 Correct 3 ms 7244 KB Output is correct
21 Correct 4 ms 7244 KB Output is correct
22 Correct 2504 ms 75488 KB Output is correct
23 Correct 1451 ms 73976 KB Output is correct
24 Correct 40 ms 10068 KB Output is correct
25 Correct 14 ms 8208 KB Output is correct
26 Correct 14 ms 8200 KB Output is correct
27 Correct 8 ms 7688 KB Output is correct
28 Correct 709 ms 34504 KB Output is correct
29 Correct 281 ms 18244 KB Output is correct
30 Correct 572 ms 23964 KB Output is correct
31 Correct 5 ms 7372 KB Output is correct
32 Correct 4 ms 7372 KB Output is correct
33 Correct 1056 ms 73876 KB Output is correct
34 Correct 913 ms 68748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 330 ms 35596 KB Output is correct
2 Correct 777 ms 54232 KB Output is correct
3 Correct 223 ms 22872 KB Output is correct
4 Correct 475 ms 37896 KB Output is correct
5 Correct 1368 ms 51632 KB Output is correct
6 Correct 311 ms 24016 KB Output is correct
7 Correct 387 ms 47696 KB Output is correct
8 Correct 504 ms 54284 KB Output is correct
9 Correct 5 ms 7500 KB Output is correct
10 Correct 290 ms 24116 KB Output is correct
11 Correct 454 ms 50756 KB Output is correct
12 Correct 421 ms 40616 KB Output is correct
13 Correct 3 ms 7244 KB Output is correct
14 Correct 301 ms 21044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 330 ms 35596 KB Output is correct
2 Correct 777 ms 54232 KB Output is correct
3 Correct 223 ms 22872 KB Output is correct
4 Correct 475 ms 37896 KB Output is correct
5 Correct 1368 ms 51632 KB Output is correct
6 Correct 311 ms 24016 KB Output is correct
7 Correct 387 ms 47696 KB Output is correct
8 Correct 504 ms 54284 KB Output is correct
9 Correct 5 ms 7500 KB Output is correct
10 Correct 290 ms 24116 KB Output is correct
11 Correct 454 ms 50756 KB Output is correct
12 Correct 421 ms 40616 KB Output is correct
13 Correct 3 ms 7244 KB Output is correct
14 Correct 301 ms 21044 KB Output is correct
15 Correct 5 ms 7244 KB Output is correct
16 Correct 4 ms 7244 KB Output is correct
17 Correct 4 ms 7244 KB Output is correct
18 Correct 4 ms 7244 KB Output is correct
19 Correct 4 ms 7244 KB Output is correct
20 Correct 38 ms 9968 KB Output is correct
21 Correct 4 ms 7244 KB Output is correct
22 Correct 3 ms 7244 KB Output is correct
23 Correct 4 ms 7244 KB Output is correct
24 Correct 4 ms 7244 KB Output is correct
25 Correct 4 ms 7372 KB Output is correct
26 Correct 6 ms 7372 KB Output is correct
27 Correct 4 ms 7244 KB Output is correct
28 Correct 3 ms 7244 KB Output is correct
29 Correct 4 ms 7244 KB Output is correct
30 Correct 4 ms 7244 KB Output is correct
31 Correct 5 ms 7244 KB Output is correct
32 Correct 5 ms 7412 KB Output is correct
33 Correct 7 ms 7628 KB Output is correct
34 Correct 3 ms 7244 KB Output is correct
35 Correct 4 ms 7244 KB Output is correct
36 Correct 2504 ms 75488 KB Output is correct
37 Correct 1451 ms 73976 KB Output is correct
38 Correct 40 ms 10068 KB Output is correct
39 Correct 14 ms 8208 KB Output is correct
40 Correct 14 ms 8200 KB Output is correct
41 Correct 8 ms 7688 KB Output is correct
42 Correct 709 ms 34504 KB Output is correct
43 Correct 281 ms 18244 KB Output is correct
44 Correct 572 ms 23964 KB Output is correct
45 Correct 5 ms 7372 KB Output is correct
46 Correct 4 ms 7372 KB Output is correct
47 Correct 1056 ms 73876 KB Output is correct
48 Correct 913 ms 68748 KB Output is correct
49 Correct 661 ms 35264 KB Output is correct
50 Correct 714 ms 34628 KB Output is correct
51 Correct 936 ms 40064 KB Output is correct
52 Correct 1199 ms 45840 KB Output is correct
53 Correct 337 ms 23124 KB Output is correct
54 Correct 1238 ms 49248 KB Output is correct
55 Correct 849 ms 54388 KB Output is correct
56 Correct 568 ms 38520 KB Output is correct
57 Incorrect 902 ms 47276 KB Output isn't correct
58 Halted 0 ms 0 KB -