제출 #795926

#제출 시각아이디문제언어결과실행 시간메모리
795926allllekssssaCheap flights (LMIO18_pigus_skrydziai)C++14
0 / 100
256 ms66400 KiB
#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], v1[maxN]; long long cnt[maxN]; 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)); } long long ans = 0; for (int i = 1; i<=n; i++) { ans = max(ans, cnt[i]); } for (int i = 1; i<= n; i++) { for (auto j: v[i]) { if (j.first > i) continue; int x = i; int y = j.first; int z = j.second; if (v[x].size() > v[y].size()) swap(x, y); v1[x].pb(mp(y, z)); } } for (int i = 1; i<=n; i++) { for (auto j: v1[i]) { for (auto k: v1[i]) cnt[k.first] = k.second; for (auto k: v1[j.first]) { cnt[k.first]+=k.second; ans = max(ans, j.second + cnt[k.first]); cnt[k.first] = 0; } for (auto k: v1[i]) { cnt[k.first] = 0; } } } cout << ans << endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:27:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |      scanf("%d%d%d", &x, &y, &z);
      |      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...