QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#643625 | #6619. Line Graph Matching | adivse# | WA | 1ms | 3680kb | C++20 | 1.8kb | 2024-10-15 22:25:52 | 2024-10-15 22:25:54 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#define endl '\n'
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define rep2(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
template<typename... Args>
void bubu(Args... args) { cout << ":: "; ((cout << args << " "), ...); cout << endl; }
void bubu(vector<int> tem) { for (auto x : tem) cout << x << ' '; cout << endl; }
void kuaidu() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); }
inline int max(int a, int b) { if (a < b) return b; return a; }
inline int min(int a, int b) { if (a < b) return a; return b; }
using PII = pair<int, int>;
using i128 = __int128;
//=======================================================================
const int N = 1e5 + 10;
const int M = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e16;
int n, m, T;
vector<PII> A[N];
int st; int in[N]; bool vis[N];
int mmin = INF;
//=======================================================================
void dfs(int x, int pa, int d) {
for (auto [y, val] : A[x]) {
if (y == pa) continue;
if (vis[y]) continue;
vis[y] = 1;
if (d % 2==0) mmin = min(mmin, val);
dfs(y, x, d + 1);
}
}
signed main() {
kuaidu();
cin >> n >> m;
int ans = 0;
rep(i, 1, m) {
int a, b, c; cin >> a >> b >> c;
A[a].push_back({ b,c });
A[b].push_back({ a,c });
in[a]++, in[b]++;
// mmin = min(mmin, c);
ans += c;
}
if (m % 2 == 0) {
cout << ans << endl;
return 0;
}
// rep(i, 1, n) {
// if (in[i] == 1) { st = i; break; }
// }
// dfs(st, 0, 0);
if (mmin >=INF/2) {
rep(i, 1, n) {
for (auto [y, val] : A[i]) mmin = min(mmin, val);
}
}
cout << ans - mmin << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3660kb
input:
5 6 1 2 1 1 3 2 1 4 3 4 3 4 4 5 5 2 5 6
output:
21
result:
ok 1 number(s): "21"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3680kb
input:
6 5 1 2 4 2 3 1 3 4 3 4 5 2 5 6 5
output:
14
result:
wrong answer 1st numbers differ - expected: '12', found: '14'