Submission #795923

# Submission time Handle Problem Language Result Execution time Memory
795923 2023-07-27T22:34:00 Z vjudge1 Cheap flights (LMIO18_pigus_skrydziai) C++17
12 / 100
3000 ms 96968 KB
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int, int>

const int maxN = 1e6 + 10;

vector<pii> v[maxN];
long long cnt[maxN];
map<pii, int> mapa;
int n, m;
int mx;

int main() {

    cin >> n >> m;
	

    for (int i = 1; i<=m; i++) {
    	int x, y, z;
    	scanf("%d%d%d", &x, &y, &z);
    	cnt[x]+=z;
    	cnt[y]+=z;
    	v[x].pb(mp(y,z));
    	v[y].pb(mp(x, z));
    	mapa[mp(x, y)] = z;
    	mapa[mp(y, x)] = z;
    	mx = max(mx, z);
    }


    long long ans = 0;

    for (int i = 1; i<=n; i++) {
    	ans = max(ans, cnt[i]);
    }

    if (mx > 1) {

    for (int x = 1; x<=n; x++) {
    	for (auto y : v[x]) {
    	for (auto z: v[y.first]) {
    			if (mapa.count(mp(x, z.first)))
    			ans = max(ans, 1ll * y.second + z.second + mapa[mp(x, z.first)]);
    		}
    	}
    }
   }

    cout << ans << endl;

	return 0;
}

Compilation message

pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:28:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |      scanf("%d%d%d", &x, &y, &z);
      |      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 13 ms 23724 KB Output is correct
4 Correct 11 ms 23696 KB Output is correct
5 Correct 14 ms 23796 KB Output is correct
6 Correct 477 ms 26704 KB Output is correct
7 Correct 13 ms 23800 KB Output is correct
8 Correct 15 ms 23764 KB Output is correct
9 Correct 13 ms 23764 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 13 ms 23836 KB Output is correct
12 Correct 14 ms 23796 KB Output is correct
13 Correct 12 ms 23764 KB Output is correct
14 Correct 12 ms 23728 KB Output is correct
15 Correct 13 ms 23776 KB Output is correct
16 Correct 12 ms 23764 KB Output is correct
17 Correct 14 ms 23680 KB Output is correct
18 Correct 15 ms 23952 KB Output is correct
19 Correct 17 ms 23992 KB Output is correct
20 Correct 13 ms 23804 KB Output is correct
21 Correct 16 ms 23680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 13 ms 23724 KB Output is correct
4 Correct 11 ms 23696 KB Output is correct
5 Correct 14 ms 23796 KB Output is correct
6 Correct 477 ms 26704 KB Output is correct
7 Correct 13 ms 23800 KB Output is correct
8 Correct 15 ms 23764 KB Output is correct
9 Correct 13 ms 23764 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 13 ms 23836 KB Output is correct
12 Correct 14 ms 23796 KB Output is correct
13 Correct 12 ms 23764 KB Output is correct
14 Correct 12 ms 23728 KB Output is correct
15 Correct 13 ms 23776 KB Output is correct
16 Correct 12 ms 23764 KB Output is correct
17 Correct 14 ms 23680 KB Output is correct
18 Correct 15 ms 23952 KB Output is correct
19 Correct 17 ms 23992 KB Output is correct
20 Correct 13 ms 23804 KB Output is correct
21 Correct 16 ms 23680 KB Output is correct
22 Execution timed out 3086 ms 96968 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 222 ms 54220 KB Output is correct
2 Correct 491 ms 73040 KB Output is correct
3 Incorrect 120 ms 40140 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 222 ms 54220 KB Output is correct
2 Correct 491 ms 73040 KB Output is correct
3 Incorrect 120 ms 40140 KB Output isn't correct
4 Halted 0 ms 0 KB -