求回复啊
  • 板块题目总版
  • 楼主lei_yu
  • 当前回复6
  • 已保存回复6
  • 发布时间2020/6/30 17:17
  • 上次更新2023/11/6 23:52:09
查看原帖
求回复啊
224927
lei_yu楼主2020/6/30 17:17

之前发的很多帖子都只有自己回复,来人啊!

P3469

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#define int long long
using namespace std;
int n,m,times,cnt,head[1000001],dfn[1000001],low[1000001],gd[1000001],gd_num[1000001],son[1000001];
struct node
{
    int to,next;
}a[5000001];
void add_edge(int from,int to)
{
    a[++cnt].to=to;
    a[cnt].next=head[from];
    head[from]=cnt;
}
void tarjan(int u,int root)
{
    int yhsb=n-1;
    int cs=0;
    dfn[u]=low[u]=++times;
    for(int i=head[u];i;i=a[i].next)
    {
        int v=a[i].to;
        if(!dfn[v])
        {
            cs++;
            tarjan(v,root);
            son[u]+=son[v];
            low[u]=min(low[u],dfn[v]);
            if(u!=root&&dfn[u]<=low[v])
            {
                gd[u]=1;
                gd_num[u]+=son[v]*(yhsb-son[v]);
                yhsb-=son[v];
                //cout<<u<<" "<<v<<" "<<gd_num[u]<<" "<<endl;
            }
        }
        else low[u]=min(low[u],dfn[v]);
    }       
    if(u==root&&cs>1)
    {
        gd[u]=1;
        //cout<<"根居然是割点!!   ";
        for(int i=head[u];i;i=a[i].next)
        {

            int v=a[i].to;
            //cout<<v<<" "<<son[v]<<" ";
            gd_num[u]+=son[v]*(yhsb-son[v]);
            yhsb-=son[v];
            //cout<<gd_num[u]<<"           ";
        }
    }
}
signed main()
{
    //freopen("P3469_1.in","r",stdin);
    //freopen("myans.txt","w",stdout);
    int x,y;
    cin>>n>>m;  
    for(int i=1;i<=n;i++)son[i]=1;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        add_edge(x,y);
        add_edge(y,x);
    }
    tarjan(1,1);
    //for(int i=1;i<=n;i++)cout<<son[i]<<" ";
    //cout<<endl;
    for(int i=1;i<=n;i++)
    {
        if(!gd[i])cout<<(n-1)*2<<endl;
        else cout<<(n-1)*2+2*gd_num[i]<<endl;
    }
}

只对了4个点!!!!!

2ab+2ac+2bc=a(b+c)+b(a+c)+c(a+b)2ab+2ac+2bc=a(b+c)+b(a+c)+c(a+b)

然而

ab+ac+bc=a(b+c)+bc+c×0ab+ac+bc=a(b+c)+bc+c×0

ab+ac+ad+bc+bd+cd=a(b+c+d)+b(c+d)+cd+d×0ab+ac+ad+bc+bd+cd=a(b+c+d)+b(c+d)+cd+d×0

qwq?qwq?

是这种思路是错的还是我的代码是错的啊?

求解

2020/6/30 17:17
加载中...