[BZOJ5407]girls
也是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的更多相关文章
- 2013成都网络赛 C We Love MOE Girls(水题)
We Love MOE Girls Time Limit: 1000/500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 123——Appium Girls活动
有感于Ruby Girls和Python Girls,在15年就想组织一次移动测试的妹子活动,框架选择Appium, 从15年夏天开始准备,申请Google的会议室,招募教练,开放报名,审核报名,到正 ...
- HDU 5145 NPY and girls 莫队+逆元
NPY and girls Problem Description NPY's girlfriend blew him out!His honey doesn't love him any more! ...
- 回文串--- Girls' research
HDU 3294 Problem Description One day, sailormoon girls are so delighted that they intend to resear ...
- POJ 1466 Girls and Boys
Girls and Boys Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=1466 Descripti ...
- 数学+高精度 ZOJ 2313 Chinese Girls' Amusement
题目传送门 /* 杭电一题(ACM_steps 2.2.4)的升级版,使用到高精度: 这次不是简单的猜出来的了,求的是GCD (n, k) == 1 最大的k(1, n/2): 1. 若n是奇数,则k ...
- Girls and Boys
Girls and Boys Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Acdream Chinese Girls' Amusement
A - Chinese Girls' Amusement Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Jav ...
- HDU----(3294)Girls' research(manacher)
Girls' research Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)T ...
随机推荐
- C# windows窗口应用程序切换主界面的显示内容
不知道说清楚没有?就是我的窗口分为两部分,左边,控制部分,由一些按钮组成右边,显示部分,由些控件(如下拉,文本等等组成) 左边的每个按钮对应显示部分的页面,也就是说,左边换一个按钮点,那么右边就显示其 ...
- MySQL:MySQL日期数据类型、MySQL时间类型使用总结
MySQL 日期类型:日期格式.所占存储空间.日期范围 比较. 日期类型 存储空间 日期格式 日期范围------------ -------- ...
- Linux负载均衡软件LVS
linux下的开源负载均衡软件LVS的安装.配置和使用.LVS是一个中国人创建和开发的开放源码项目,利用LVS可以构建高可用.高可靠的负载均衡集群,因此,利用Linux+LVS不但可以假设高性能的负载 ...
- Fiddler正则匹配调试接口示例
Fiddler基础知识 Fiddler是强大的抓包工具,它的原理是以web代理服务器的形式进行工作的,使用的代理地址是:127.0.0.1,端口默认为8888,我们也可以通过设置进行修改. 代理就是在 ...
- BaseActivity 基类
public abstract class BaseActivity extends AppCompatActivity implements IBaseView { private ProxyAct ...
- ZOJ 3822 ( 2014牡丹江区域赛D题) (概率dp)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5376 题意:每天往n*m的棋盘上放一颗棋子,求多少天能将棋盘的每行每列都至少有 ...
- selenium 访问网页抛出ElementNotVisibleException异常
问题描述: 在使用selenium时遇到如下异常导致程序终止: selenium.common.exceptions.ElementNotVisibleException: Message: {&qu ...
- Note-Git:Git 笔记
ylbtech-Note-Git:Git 笔记 1.返回顶部 · Git 分支管理: 主干/master.热修正/hotfix.预生产/release.开发develop.个人1(个人.小团队)/f ...
- Web安全测试——常见的威胁攻防
SQL注入 部分程序员在编写代码的时候,没有对用户输入数据的合法性进行判断,使应用程序存在安全隐患.用户可以提交一段数据库查询代码,根据程序返回的结果,获得某些他想得知的数据,这就是所谓的SQL In ...
- JS动态添加Easyui的HTML时样式丢失
解决办法: $.parser.parse($("#creatLi").html(<li>xxxxxx</li>)); ------------------- ...