이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
using namespace std;
const int N=3e5+5;
int n,m;
map < int , int > f[N];
vector < pair < int , ll > > v[N];
main() {
ios::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
cin>>n>>m;
for (int i=1; i<=m; i++) {
int a,b,c;
cin>>a>>b>>c;
v[a].pb({b,c});
v[b].pb({a,c});
f[a][b]=max(f[a][b],c);
f[b][a]=max(f[b][a],c);
}
ll ans=0;
for (int i=1; i<=n; i++) {
ll res=0;
pair < int , ll > M1={-1,-1},M2={-1,-1};
for (int j=0; j<v[i].size(); j++) {
res+=v[i][j].S;
if (v[i][j].S>M1.S) M2=M1,M1=v[i][j];
else
if (v[i][j].S>M2.S) M2=v[i][j];
}
ans=max(ans,res);
if (M1.F==-1 || M2.F==-1)
continue;
ans=max(ans,M1.S+M2.S+f[M1.F][M2.F]);
}
cout<<ans<<"\n";
}
컴파일 시 표준 에러 (stderr) 메시지
pigus_skrydziai.cpp:16:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
16 | main() {
| ^
pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for (int j=0; j<v[i].size(); j++) {
| ~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |