也是CF985G。。。
容斥+三元环计数
CF数据太弱啦
vis没赋初值-1竟然过了QAQ
所以又调了我半个小时才搞掉QAQ
数数真难QAQ
记得要写#include<vector>!!!
Dev给加的奇奇怪怪的编译选项会给你自动填补的!!!
QAQ长个记性QAQ
#include#include #include #include #include #define ull unsigned long long#define ll long long#define inf 20021225#define N 400010#define it vector ::iteratorusing namespace std; int sz[N],deg[N],n,m;vector sum[N];vector 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<0) return 0; return (ll)x*(x-1)/2;}ull up(int l,int r){ if(l>r) return 0; return (ll)(r+l)*(r-l+1)/2;}int main(){ scanf("%d%d",&n,&m); ull A,B,C,res=0; scanf("%llu%llu%llu",&A,&B,&C); int x,y; //scanf("%I64d%I64d%I64d",&A,&B,&C); int x,y; for(int i=1;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=0;i x?sz[x]:sz[x]+1,++deg[x],sum[x].push_back(sum[x][deg[x]-1]+(*i)); //at least 1 for(x=0;x 0?x-y-1:0); res-=C*x*(x-1); } //printf("%llu\n",res); //at least 2 //int dig; //printf("%llu\n",res); for(x=0;x 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 y) swap(x,y); if(x>z) swap(x,z); res-=A*x+B*y+C*z; } } } else big.push_back(i); }*/ for(x=0;x 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 0;}/**4 12 3 41 0*/
由于这个题调的我太过痛苦 写作业都写不进去
bug列举一下
1.我不会冒泡排序排三个数
2.(0,n-1)看成(1,n)重调系数非常蛋疼
3.初值就是忘了赋
4.系数和值少一个
5.手贱