QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#217103 | #6619. Line Graph Matching | zhuibao | WA | 65ms | 21244kb | C++20 | 1.7kb | 2023-10-16 14:55:47 | 2023-10-16 14:55:47 |
Judging History
answer
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll>pi; typedef complex<double>cx;
#define int ll
#define X first
#define Y second
#define fer(i,a,n) for(int i=a;i<=n;i++)
#define ref(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a,x) memset(a,x,sizeof a)
#define ac IO;int t;cin>>t;while(t--)solve()
#define AC signed main(){IO;solve();}
#define NO {cout<<"NO"<<endl;return;}
#define YES {cout<<"YES"<<endl;return;}
#define re(a) {cout<<a<<endl;return;}
#define all(v) v.begin(),v.end()
//ofstream fout("1.out", ios::out);
//ifstream fin("1.in", ios::in);
//#define cout fout
//#define cin fin
//--------------------瑞神神中神--------------------
const int N=2e5+10;
int low[N],dfn[N];
vector<pi>e[N];
set<int>vec;
int n,m,tim,cnt;
void tarjan(int u,int fa)
{
low[u]=dfn[u]=++tim;
for(auto[v,w]:e[u])
{
if(v==fa)continue;
int tmp=cnt++;
if(!dfn[v])
{
tarjan(v,u);
low[u]=min(low[u],low[v]);
if(low[v]>dfn[u]&&(tmp&1))
{
vec.erase(w);
}
}
else if(dfn[v]<dfn[u])
{
low[u]=min(low[u],dfn[v]);
}
}
}
void solve()
{
cin>>n>>m;
int ans=0;
for(int i=1;i<=m;i++)
{
int a,b,c;
cin>>a>>b>>c;
ans+=c;
e[a].emplace_back(b,c);
e[b].emplace_back(a,c);
vec.insert(c);
}
if(!(m&1))
{
cout<<ans<<'\n';
return;
}
tarjan(1,0);
ans-=*vec.begin();
cout<<ans<<'\n';
}
AC
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 10264kb
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: 0
Accepted
time: 2ms
memory: 10976kb
input:
6 5 1 2 4 2 3 1 3 4 3 4 5 2 5 6 5
output:
12
result:
ok 1 number(s): "12"
Test #3:
score: 0
Accepted
time: 0ms
memory: 9692kb
input:
5 5 1 2 1 2 3 2 3 4 3 4 5 4 5 1 5
output:
14
result:
ok 1 number(s): "14"
Test #4:
score: 0
Accepted
time: 1ms
memory: 9488kb
input:
3 2 1 2 1 2 3 2
output:
3
result:
ok 1 number(s): "3"
Test #5:
score: 0
Accepted
time: 1ms
memory: 10556kb
input:
3 3 1 2 3 2 3 1 3 1 2
output:
5
result:
ok 1 number(s): "5"
Test #6:
score: 0
Accepted
time: 1ms
memory: 9744kb
input:
6 7 1 2 1 2 3 2 3 4 3 4 1 4 4 5 5 5 6 6 6 4 7
output:
27
result:
ok 1 number(s): "27"
Test #7:
score: -100
Wrong Answer
time: 65ms
memory: 21244kb
input:
100000 99999 54273 5761 179909546 6472 21601 924153552 610 22693 767540137 37784 2454 951330587 24457 93770 781030280 36098 27 448166069 21292 43394 244510129 58047 86330 869927899 18770 83124 20504174 24036 92856 8370757 92492 21932 734860719 43776 77624 226721931 15746 70738 429430538 71204 87185 ...
output:
49946352879812
result:
wrong answer 1st numbers differ - expected: '49946352904479', found: '49946352879812'