이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("talent.in");
ofstream fout("talent.out");
#define ll long long
#define vt vector
#define pb push_back
#define fi first
#define se second
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int long long
typedef unsigned long long ull;
const int mxn = 3e5 + 3;
int n, m;
ll c[mxn + 1];
struct e{
ll u, v, w;
};
vt<e>edge;
vt<pii>adj[mxn + 1];
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
forr(i, 0, m){
int u, v; cin >> u >> v; ll w; cin >> w;
adj[u].pb({v, w}); adj[v].pb({u, w});
edge.pb({u, v, w});
c[u] += w; c[v] += w;
}
ll ans =0;
forr(i, 1, n + 1)ans = max(ans, c[i]);
// triangle
for(auto [u, v, w]: edge){
bool swapp = adj[u].size() > adj[v].size();
if(swapp)swap(adj[u], adj[v]);
for(auto [t, e]: adj[u]){
int id = lower_bound(adj[v].begin(), adj[v].end(), make_pair(t, (ll)-1)) - adj[v].begin();
if(id != adj[v].size() && adj[v][id].fi == t){
//cout << u << " " << v << " " << t << "\n";
ans = max(ans, e + w + adj[v][id].se);
}
}
if(swapp)swap(adj[u], adj[v]);
}
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:40:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
40 | for(auto [u, v, w]: edge){
| ^
pigus_skrydziai.cpp:43:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
43 | for(auto [t, e]: adj[u]){
| ^
pigus_skrydziai.cpp:45:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if(id != adj[v].size() && adj[v][id].fi == t){
| ~~~^~~~~~~~~~~~~~~~
# | 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... |