也是CF985G。。。

容斥+三元环计数

CF数据太弱啦

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

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

数数真难QAQ

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

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

QAQ长个记性QAQ

  1. #include<cstdio>
  2. #include<cmath>
  3. #include<algorithm>
  4. #include<cstring>
  5. #include<vector>
  6. #define ull unsigned long long
  7. #define ll long long
  8. #define inf 20021225
  9. #define N 400010
  10. #define it vector<int>::iterator
  11. using namespace std;
  12.  
  13. int sz[N],deg[N],n,m;
  14. vector<ull> sum[N];
  15. vector<int> ed[N];
  16. struct edge{int to,lt;}e[N];
  17. int in[N],cnt; int vis[N];
  18. void add(int x,int y){e[++cnt].to=y;e[cnt].lt=in[x];in[x]=cnt;}
  19. void go(int x){for(int i=in[x];i;i=e[i].lt) vis[e[i].to]=x;}
  20. ull calc(int x){if(x<) return ; return (ll)x*(x-)/;}
  21. ull up(int l,int r){if(l>r) return ; return (ll)(r+l)*(r-l+)/;}
  22. int main()
  23. {
  24. scanf("%d%d",&n,&m); ull A,B,C,res=;
  25. scanf("%llu%llu%llu",&A,&B,&C); int x,y;
  26. //scanf("%I64d%I64d%I64d",&A,&B,&C); int x,y;
  27. for(int i=;i<=m;i++)
  28. {
  29. scanf("%d%d",&x,&y);
  30. ed[x].push_back(y);
  31. ed[y].push_back(x);
  32. }
  33. //ull edg=(ull)n*(n-1)>>1;
  34. //at least 0
  35. for(int i=;i<n;i++)
  36. res+=A*i*calc(n-i-),
  37. res+=B*i*i*(n-i-),
  38. res+=C*i*calc(i),
  39. sort(ed[i].begin(),ed[i].end()),
  40. sum[i].push_back();
  41. //printf("%llu\n",res);
  42. for(x=;x<n;x++) for(it i=ed[x].begin();i!=ed[x].end();i++)
  43. sz[x]=(*i)>x?sz[x]:sz[x]+,++deg[x],sum[x].push_back(sum[x][deg[x]-]+(*i));
  44. //at least 1
  45. for(x=;x<n;x++) for(it i=ed[x].begin();i!=ed[x].end();i++)
  46. if((*i)<x)
  47. {
  48. y=*i;
  49. //x as B
  50. res-=B*x*(n-x-);
  51. res-=A*y*(n-x-);
  52. res-=C*up(x+,n-);
  53. //x as C
  54. res-=A*up(,y-);
  55. res-=B*y*y;
  56. res-=B*up(y+,x-);
  57. res-=A*y*(x-y->?x-y-:);
  58. res-=C*x*(x-);
  59. }
  60. //printf("%llu\n",res);
  61. //at least 2
  62. //int dig;
  63. //printf("%llu\n",res);
  64. for(x=;x<n;x++) for(int i=;i<=deg[x];i++)
  65. {
  66. //printf("%d %llu\n",x,sum[x][i]);
  67. //x has 2 edges out
  68. y=ed[x][i-];
  69. if(y>x)
  70. {
  71. //x is A
  72. res+=A*x*(deg[x]-i); res+=B*y*(deg[x]-i);
  73. res+=C*(sum[x][deg[x]]-sum[x][i]);
  74. //printf("%d %d %llu\n",x,y,res);
  75. }
  76. else// if(y<x)
  77. {
  78. //x is B
  79. res+=B*x*(deg[x]-sz[x]); res+=A*y*(deg[x]-sz[x]);
  80. res+=C*(sum[x][deg[x]]-sum[x][sz[x]]);
  81. //x is C
  82. res+=C*x*(i-); res+=B*y*(i-);
  83. res+=A*sum[x][i-];
  84. }
  85. }
  86. //printf("%llu\n",res);
  87. //at least 3
  88. /**for(int i=1;i<=n;i++)
  89. {
  90. if(deg[i]<=top)
  91. {
  92. for(int j=0;j<deg[i];j++)
  93. {
  94. for(int k=j+1;k<deg[i];k++)
  95. {
  96. x=i; y=ed[x][j]; z=ed[x][k];
  97. if(x>y) swap(x,y);
  98. if(x>z) swap(x,z);
  99. res-=A*x+B*y+C*z;
  100. }
  101. }
  102. }
  103. else big.push_back(i);
  104. }*/
  105. for(x=;x<n;x++) for(int i=;i<deg[x];i++)
  106. if(deg[ed[x][i]]<deg[x] || (deg[ed[x][i]]==deg[x]&&ed[x][i]<x))
  107. add(x,ed[x][i]);
  108. memset(vis,-,sizeof(vis));
  109. for(x=;x<n;x++)
  110. {
  111. go(x);
  112. for(int i=in[x];i;i=e[i].lt)
  113. {
  114. y=e[i].to;
  115. for(int j=in[y];j;j=e[j].lt)
  116. {
  117. if(vis[e[j].to]==x)
  118. {
  119. int xx=x,yy=y,zz=e[j].to;
  120. if(xx>yy) swap(xx,yy);
  121. if(xx>zz) swap(xx,zz);
  122. if(yy>zz) swap(yy,zz);
  123. res-=A*xx+B*yy+C*zz;
  124. }
  125. }
  126. }
  127. }
  128. printf("%llu\n",res);
  129. //printf("%I64u\n",res);
  130. return ;
  131. }
  132. /**
  133. 4 1
  134. 2 3 4
  135. 1 0
  136. */

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

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. C# windows窗口应用程序切换主界面的显示内容

    不知道说清楚没有?就是我的窗口分为两部分,左边,控制部分,由一些按钮组成右边,显示部分,由些控件(如下拉,文本等等组成) 左边的每个按钮对应显示部分的页面,也就是说,左边换一个按钮点,那么右边就显示其 ...

  2. MySQL:MySQL日期数据类型、MySQL时间类型使用总结

    MySQL 日期类型:日期格式.所占存储空间.日期范围 比较. 日期类型        存储空间      日期格式                日期范围------------  -------- ...

  3. Linux负载均衡软件LVS

    linux下的开源负载均衡软件LVS的安装.配置和使用.LVS是一个中国人创建和开发的开放源码项目,利用LVS可以构建高可用.高可靠的负载均衡集群,因此,利用Linux+LVS不但可以假设高性能的负载 ...

  4. Fiddler正则匹配调试接口示例

    Fiddler基础知识 Fiddler是强大的抓包工具,它的原理是以web代理服务器的形式进行工作的,使用的代理地址是:127.0.0.1,端口默认为8888,我们也可以通过设置进行修改. 代理就是在 ...

  5. BaseActivity 基类

    public abstract class BaseActivity extends AppCompatActivity implements IBaseView { private ProxyAct ...

  6. ZOJ 3822 ( 2014牡丹江区域赛D题) (概率dp)

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5376 题意:每天往n*m的棋盘上放一颗棋子,求多少天能将棋盘的每行每列都至少有 ...

  7. selenium 访问网页抛出ElementNotVisibleException异常

    问题描述: 在使用selenium时遇到如下异常导致程序终止: selenium.common.exceptions.ElementNotVisibleException: Message: {&qu ...

  8. Note-Git:Git 笔记

    ylbtech-Note-Git:Git 笔记 1.返回顶部 ·  Git 分支管理: 主干/master.热修正/hotfix.预生产/release.开发develop.个人1(个人.小团队)/f ...

  9. Web安全测试——常见的威胁攻防

    SQL注入 部分程序员在编写代码的时候,没有对用户输入数据的合法性进行判断,使应用程序存在安全隐患.用户可以提交一段数据库查询代码,根据程序返回的结果,获得某些他想得知的数据,这就是所谓的SQL In ...

  10. JS动态添加Easyui的HTML时样式丢失

    解决办法: $.parser.parse($("#creatLi").html(<li>xxxxxx</li>)); ------------------- ...