版本比较
题解:P7384 「EZEC-6」分组
正文
增加 6 行删除 6 行
16 行未改动171819202121222324242526272829303132323334353616 行未改动535455565757585960617 行未改动6970717273737475767777787980813 行未改动16 行未改动#include <bits/stdc++.h>using namespace std;#define gc()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)char buf[1<<21],*p1=buf,*p2=buf;#define int long long #define int long long#define rint register inttemplate <typename T>inline void read(T& r) inline void read(T& r){ r=0;bool w=0; char ch=gc(); while(ch<'0'||ch>'9') w=ch=='-'?1:0,ch=gc(); while(ch>='0'&&ch<='9') r=(r<<1)+(r<<3)+(ch^48), ch=gc(); r=w?-r:r;}int f[61],g[61];inline int find(int x) inline int find(int x){ while(f[x]!=x) { f[x]=f[f[x]],x=f[x];16 行未改动 for(rint i=0;i<=60;++i) f[i]=i; for(rint i=1;i<=n;++i) { read(a[i]); if(!a[i]) if(!a[i]) { ++ans;//为0的先加 continue; }7 行未改动 if(g[j]&(1ll<<i))//如果组j和i最高位有一位相同 { if(last!=-1) merge(last,j); last=j; } } } } for(rint i=0;i<=60;++i) { { if(g[i]&&f[i]==i) ++ans; } printf("%lld",ans); return 0;3 行未改动