QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#242986#6619. Line Graph MatchingRonbogoWA 1ms5744kbC++201.2kb2023-11-07 19:23:522023-11-07 19:23:53

Judging History

你现在查看的是最新测评结果

  • [2023-11-07 19:23:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5744kb
  • [2023-11-07 19:23:52]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'