也是CF985G。。。

容斥+三元环计数

CF数据太弱啦

vis没赋初值-1竟然过了QAQ

所以又调了我半个小时才搞掉QAQ

数数真难QAQ

记得要写#include<vector>!!!

Dev给加的奇奇怪怪的编译选项会给你自动填补的!!!

QAQ长个记性QAQ

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#define ull unsigned long long
#define ll long long
#define inf 20021225
#define N 400010
#define it vector<int>::iterator
using namespace std; int sz[N],deg[N],n,m;
vector<ull> sum[N];
vector<int> ed[N];
struct edge{int to,lt;}e[N];
int in[N],cnt; int vis[N];
void add(int x,int y){e[++cnt].to=y;e[cnt].lt=in[x];in[x]=cnt;}
void go(int x){for(int i=in[x];i;i=e[i].lt) vis[e[i].to]=x;}
ull calc(int x){if(x<) return ; return (ll)x*(x-)/;}
ull up(int l,int r){if(l>r) return ; return (ll)(r+l)*(r-l+)/;}
int main()
{
scanf("%d%d",&n,&m); ull A,B,C,res=;
scanf("%llu%llu%llu",&A,&B,&C); int x,y;
//scanf("%I64d%I64d%I64d",&A,&B,&C); int x,y;
for(int i=;i<=m;i++)
{
scanf("%d%d",&x,&y);
ed[x].push_back(y);
ed[y].push_back(x);
}
//ull edg=(ull)n*(n-1)>>1;
//at least 0
for(int i=;i<n;i++)
res+=A*i*calc(n-i-),
res+=B*i*i*(n-i-),
res+=C*i*calc(i),
sort(ed[i].begin(),ed[i].end()),
sum[i].push_back();
//printf("%llu\n",res);
for(x=;x<n;x++) for(it i=ed[x].begin();i!=ed[x].end();i++)
sz[x]=(*i)>x?sz[x]:sz[x]+,++deg[x],sum[x].push_back(sum[x][deg[x]-]+(*i));
//at least 1
for(x=;x<n;x++) for(it i=ed[x].begin();i!=ed[x].end();i++)
if((*i)<x)
{
y=*i;
//x as B
res-=B*x*(n-x-);
res-=A*y*(n-x-);
res-=C*up(x+,n-);
//x as C
res-=A*up(,y-);
res-=B*y*y;
res-=B*up(y+,x-);
res-=A*y*(x-y->?x-y-:);
res-=C*x*(x-);
}
//printf("%llu\n",res);
//at least 2
//int dig;
//printf("%llu\n",res);
for(x=;x<n;x++) for(int i=;i<=deg[x];i++)
{
//printf("%d %llu\n",x,sum[x][i]);
//x has 2 edges out
y=ed[x][i-];
if(y>x)
{
//x is A
res+=A*x*(deg[x]-i); res+=B*y*(deg[x]-i);
res+=C*(sum[x][deg[x]]-sum[x][i]);
//printf("%d %d %llu\n",x,y,res);
}
else// if(y<x)
{
//x is B
res+=B*x*(deg[x]-sz[x]); res+=A*y*(deg[x]-sz[x]);
res+=C*(sum[x][deg[x]]-sum[x][sz[x]]);
//x is C
res+=C*x*(i-); res+=B*y*(i-);
res+=A*sum[x][i-];
}
}
//printf("%llu\n",res);
//at least 3
/**for(int i=1;i<=n;i++)
{
if(deg[i]<=top)
{
for(int j=0;j<deg[i];j++)
{
for(int k=j+1;k<deg[i];k++)
{
x=i; y=ed[x][j]; z=ed[x][k];
if(x>y) swap(x,y);
if(x>z) swap(x,z);
res-=A*x+B*y+C*z;
}
}
}
else big.push_back(i);
}*/
for(x=;x<n;x++) for(int i=;i<deg[x];i++)
if(deg[ed[x][i]]<deg[x] || (deg[ed[x][i]]==deg[x]&&ed[x][i]<x))
add(x,ed[x][i]);
memset(vis,-,sizeof(vis));
for(x=;x<n;x++)
{
go(x);
for(int i=in[x];i;i=e[i].lt)
{
y=e[i].to;
for(int j=in[y];j;j=e[j].lt)
{
if(vis[e[j].to]==x)
{
int xx=x,yy=y,zz=e[j].to;
if(xx>yy) swap(xx,yy);
if(xx>zz) swap(xx,zz);
if(yy>zz) swap(yy,zz);
res-=A*xx+B*yy+C*zz;
}
}
}
}
printf("%llu\n",res);
//printf("%I64u\n",res);
return ;
}
/**
4 1
2 3 4
1 0
*/

由于这个题调的我太过痛苦 写作业都写不进去

bug列举一下

1.我不会冒泡排序排三个数

2.(0,n-1)看成(1,n)重调系数非常蛋疼

3.初值就是忘了赋

4.系数和值少一个

5.手贱

[BZOJ5407]girls的更多相关文章

  1. 2013成都网络赛 C We Love MOE Girls(水题)

    We Love MOE Girls Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  2. 123——Appium Girls活动

    有感于Ruby Girls和Python Girls,在15年就想组织一次移动测试的妹子活动,框架选择Appium, 从15年夏天开始准备,申请Google的会议室,招募教练,开放报名,审核报名,到正 ...

  3. HDU 5145 NPY and girls 莫队+逆元

    NPY and girls Problem Description NPY's girlfriend blew him out!His honey doesn't love him any more! ...

  4. 回文串--- Girls' research

    HDU   3294 Problem Description One day, sailormoon girls are so delighted that they intend to resear ...

  5. POJ 1466 Girls and Boys

    Girls and Boys Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=1466 Descripti ...

  6. 数学+高精度 ZOJ 2313 Chinese Girls' Amusement

    题目传送门 /* 杭电一题(ACM_steps 2.2.4)的升级版,使用到高精度: 这次不是简单的猜出来的了,求的是GCD (n, k) == 1 最大的k(1, n/2): 1. 若n是奇数,则k ...

  7. Girls and Boys

    Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. Acdream Chinese Girls' Amusement

    A - Chinese Girls' Amusement Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Jav ...

  9. HDU----(3294)Girls' research(manacher)

    Girls' research Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)T ...

随机推荐

  1. 打印XX提交的svn版本信息

    打印出匹配uliuchao或--结尾的行 svn log | sed -n '/uliuchao/,/--$/p'

  2. flutter中的按钮组件

    Flutter 里有很多的 Button 组件很多,常见的按钮组件有:RaisedButton.FlatButton.IconButton.OutlineButton.ButtonBar.Floati ...

  3. JS求多个数组的重复数据

    今天朋友问了我这个问题:JS求多个数组的重复数据 注: 1.更准确的说是只要多个数组中有两个以上的重复数据,那么这个数据就是我需要的 2.单个数组内的数据不存在重复值(当然如果有的话,你可以去重) 3 ...

  4. codeforces 617 E. XOR and Favorite Number(莫队算法)

    题目链接:http://codeforces.com/problemset/problem/617/E 题目: 给你a1 a2 a3 ··· an 个数,m次询问:在[L, R] 里面又多少中 [l, ...

  5. Log4j appender、layout

    appender输出类型配置 layout日志信息格式 Threshold属性指定输出等级 Append属性指定是否追加内容 (1)appender输出类型配置 Log4j官方的appender给出了 ...

  6. 多个springboot项目部署到tomcat,Error deploying web application archive

    每个springboot单独部署到tomcat下可以正常启动,多个一个就发生异常 Error deploying web application archive 解决:配置文件加上配置区分 sprin ...

  7. NaN、null、undefined的那些事

    一.NaN , NaN, 'abc', false] let newArray = JSON.parse(JSON.stringify(arr)) // [1, null, 'abc', false] ...

  8. tp5.1 phpspreadsheet- 工具类 导入导出(整合优化,非原创,抄一抄,加了一些自己的东西,)

    phpspreadsheet-工具类 导入导出(整合优化,非原创,抄一抄,加了一些自己的东西)1. composer require phpoffice/phpspreadsheet2. 看最下面的两 ...

  9. tensorflow学习框架(炼数成金网络版学习记录)

    chapter1 #变量 import tensorflow as tf x = tf.Variable([1,2]) a = tf.constant([3,3]) #增加一个减法op sub = t ...

  10. [Python3] 024 面向对象 第四弹

    目录 11. 类和对象的三种方法 12. 抽象类 12.1 抽象方法 12.2 抽象类 12.3 抽象类的使用 13. 自定义类 接上一篇 [Python3] 023 面向对象 第三弹 11. 类和对 ...