#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 < 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';
}
Compilation message
pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:39:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int j = 0; j < 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
| ~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
7332 KB |
Output is correct |
5 |
Correct |
3 ms |
7244 KB |
Output is correct |
6 |
Correct |
37 ms |
10064 KB |
Output is correct |
7 |
Correct |
3 ms |
7332 KB |
Output is correct |
8 |
Correct |
4 ms |
7344 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 |
5 ms |
7372 KB |
Output is correct |
13 |
Correct |
4 ms |
7372 KB |
Output is correct |
14 |
Correct |
4 ms |
7244 KB |
Output is correct |
15 |
Correct |
4 ms |
7244 KB |
Output is correct |
16 |
Correct |
5 ms |
7332 KB |
Output is correct |
17 |
Correct |
3 ms |
7244 KB |
Output is correct |
18 |
Correct |
5 ms |
7372 KB |
Output is correct |
19 |
Correct |
6 ms |
7628 KB |
Output is correct |
20 |
Correct |
4 ms |
7244 KB |
Output is correct |
21 |
Correct |
3 ms |
7244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
7332 KB |
Output is correct |
5 |
Correct |
3 ms |
7244 KB |
Output is correct |
6 |
Correct |
37 ms |
10064 KB |
Output is correct |
7 |
Correct |
3 ms |
7332 KB |
Output is correct |
8 |
Correct |
4 ms |
7344 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 |
5 ms |
7372 KB |
Output is correct |
13 |
Correct |
4 ms |
7372 KB |
Output is correct |
14 |
Correct |
4 ms |
7244 KB |
Output is correct |
15 |
Correct |
4 ms |
7244 KB |
Output is correct |
16 |
Correct |
5 ms |
7332 KB |
Output is correct |
17 |
Correct |
3 ms |
7244 KB |
Output is correct |
18 |
Correct |
5 ms |
7372 KB |
Output is correct |
19 |
Correct |
6 ms |
7628 KB |
Output is correct |
20 |
Correct |
4 ms |
7244 KB |
Output is correct |
21 |
Correct |
3 ms |
7244 KB |
Output is correct |
22 |
Correct |
2524 ms |
75620 KB |
Output is correct |
23 |
Correct |
1306 ms |
74036 KB |
Output is correct |
24 |
Correct |
40 ms |
10100 KB |
Output is correct |
25 |
Correct |
14 ms |
8140 KB |
Output is correct |
26 |
Correct |
14 ms |
8176 KB |
Output is correct |
27 |
Correct |
7 ms |
7628 KB |
Output is correct |
28 |
Correct |
674 ms |
34504 KB |
Output is correct |
29 |
Correct |
307 ms |
18248 KB |
Output is correct |
30 |
Correct |
510 ms |
24088 KB |
Output is correct |
31 |
Correct |
6 ms |
7372 KB |
Output is correct |
32 |
Correct |
6 ms |
7372 KB |
Output is correct |
33 |
Correct |
1018 ms |
73928 KB |
Output is correct |
34 |
Correct |
858 ms |
68732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
329 ms |
35524 KB |
Output is correct |
2 |
Correct |
771 ms |
58764 KB |
Output is correct |
3 |
Correct |
205 ms |
24264 KB |
Output is correct |
4 |
Correct |
483 ms |
40656 KB |
Output is correct |
5 |
Correct |
1401 ms |
56080 KB |
Output is correct |
6 |
Correct |
265 ms |
25196 KB |
Output is correct |
7 |
Correct |
411 ms |
51376 KB |
Output is correct |
8 |
Correct |
587 ms |
58696 KB |
Output is correct |
9 |
Correct |
6 ms |
7500 KB |
Output is correct |
10 |
Correct |
282 ms |
25256 KB |
Output is correct |
11 |
Correct |
476 ms |
53784 KB |
Output is correct |
12 |
Correct |
481 ms |
43120 KB |
Output is correct |
13 |
Correct |
3 ms |
7244 KB |
Output is correct |
14 |
Correct |
282 ms |
22104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
329 ms |
35524 KB |
Output is correct |
2 |
Correct |
771 ms |
58764 KB |
Output is correct |
3 |
Correct |
205 ms |
24264 KB |
Output is correct |
4 |
Correct |
483 ms |
40656 KB |
Output is correct |
5 |
Correct |
1401 ms |
56080 KB |
Output is correct |
6 |
Correct |
265 ms |
25196 KB |
Output is correct |
7 |
Correct |
411 ms |
51376 KB |
Output is correct |
8 |
Correct |
587 ms |
58696 KB |
Output is correct |
9 |
Correct |
6 ms |
7500 KB |
Output is correct |
10 |
Correct |
282 ms |
25256 KB |
Output is correct |
11 |
Correct |
476 ms |
53784 KB |
Output is correct |
12 |
Correct |
481 ms |
43120 KB |
Output is correct |
13 |
Correct |
3 ms |
7244 KB |
Output is correct |
14 |
Correct |
282 ms |
22104 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 |
7332 KB |
Output is correct |
19 |
Correct |
3 ms |
7244 KB |
Output is correct |
20 |
Correct |
37 ms |
10064 KB |
Output is correct |
21 |
Correct |
3 ms |
7332 KB |
Output is correct |
22 |
Correct |
4 ms |
7344 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 |
5 ms |
7372 KB |
Output is correct |
27 |
Correct |
4 ms |
7372 KB |
Output is correct |
28 |
Correct |
4 ms |
7244 KB |
Output is correct |
29 |
Correct |
4 ms |
7244 KB |
Output is correct |
30 |
Correct |
5 ms |
7332 KB |
Output is correct |
31 |
Correct |
3 ms |
7244 KB |
Output is correct |
32 |
Correct |
5 ms |
7372 KB |
Output is correct |
33 |
Correct |
6 ms |
7628 KB |
Output is correct |
34 |
Correct |
4 ms |
7244 KB |
Output is correct |
35 |
Correct |
3 ms |
7244 KB |
Output is correct |
36 |
Correct |
2524 ms |
75620 KB |
Output is correct |
37 |
Correct |
1306 ms |
74036 KB |
Output is correct |
38 |
Correct |
40 ms |
10100 KB |
Output is correct |
39 |
Correct |
14 ms |
8140 KB |
Output is correct |
40 |
Correct |
14 ms |
8176 KB |
Output is correct |
41 |
Correct |
7 ms |
7628 KB |
Output is correct |
42 |
Correct |
674 ms |
34504 KB |
Output is correct |
43 |
Correct |
307 ms |
18248 KB |
Output is correct |
44 |
Correct |
510 ms |
24088 KB |
Output is correct |
45 |
Correct |
6 ms |
7372 KB |
Output is correct |
46 |
Correct |
6 ms |
7372 KB |
Output is correct |
47 |
Correct |
1018 ms |
73928 KB |
Output is correct |
48 |
Correct |
858 ms |
68732 KB |
Output is correct |
49 |
Correct |
743 ms |
37816 KB |
Output is correct |
50 |
Correct |
715 ms |
38440 KB |
Output is correct |
51 |
Correct |
966 ms |
44084 KB |
Output is correct |
52 |
Correct |
1247 ms |
50440 KB |
Output is correct |
53 |
Correct |
281 ms |
25132 KB |
Output is correct |
54 |
Correct |
1265 ms |
53824 KB |
Output is correct |
55 |
Correct |
827 ms |
58712 KB |
Output is correct |
56 |
Correct |
522 ms |
43156 KB |
Output is correct |
57 |
Incorrect |
830 ms |
51568 KB |
Output isn't correct |
58 |
Halted |
0 ms |
0 KB |
- |