QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#242986 | #6619. Line Graph Matching | Ronbogo | WA | 1ms | 5744kb | C++20 | 1.2kb | 2023-11-07 19:23:52 | 2023-11-07 19:23:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const long long N=1e5+10,M=2e5+10;
long long head[N], idx;
struct Edge{int to,nxt,d;}e[M<<1];
void add(int u, int v, int d) {e[++idx].to = v;e[idx].nxt=head[u];e[idx].d=d;head[u]=idx;}
int din[N],siz[N],ans,minn,cnt,sum;
int dfn[N],low[N],dfscnt;
void tarjan(int u,int fa)
{
dfn[u]=low[u]=++dfscnt;
siz[u]=din[u];
for (int i=head[u];i;i=e[i].nxt) {
int v=e[i].to, d = e[i].d;
if (!dfn[v]) {
tarjan(v,u);
siz[u]+=siz[v];
low[u]=min(low[u],low[v]);
if (low[v]>dfn[u]) {
if ((((siz[v]-1)/2)&1)==0){minn=min(minn,d);}
}else {minn=min(minn,d);}
}else if (v!=fa){minn=min(minn,d);low[u]=min(low[u],dfn[v]);}
if (dfn[u]<dfn[v]){cnt++;}
}
}
int main()
{
int n,m;
cin>>n>>m;
for (int i=1;i<=m;i++){
int u,v,d;
cin>>u>>v>>d;
ans+=d;
add(u,v,d);add(v,u,d);
din[u]++;din[v]++;
}
for (int i = 1; i <= n; i++) {
if (!dfn[i]) {
minn =2e9;cnt=0;sum=0;
tarjan(i,0);
}
}
cout<<ans;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5744kb
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: 0ms
memory: 3512kb
input:
6 5 1 2 4 2 3 1 3 4 3 4 5 2 5 6 5
output:
15
result:
wrong answer 1st numbers differ - expected: '12', found: '15'