이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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<ll> adj[MAX];
map<pair<ll, ll>, ll> pe;
int main()
{
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int N, M;
cin >> N >> M;
for(int i = 0; i < M; i++)
{
ll 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(ll sidx : adj[i])
{
sum_zv += pe[{i, sidx}];
}
// perrenkam trikampius
for(int j = 0; j < adj[i].size()-1; j++)
{
ll kaim1 = adj[i][j];
ll kaim2 = adj[i][j+1];
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}];
}
if(sum_zv > mx) mx = sum_zv;
if(sum_tr > mx) mx = sum_tr;
}
cout << mx << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(int j = 0; j < adj[i].size()-1; 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... |