Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 我的加读入优化后才30多行

Posted by xzy_xzy at 2019-06-22 20:06:36 on Problem 1182
```#include <cstdio>

{
int x=0,f=1;char c=getchar();
while (c<'0' || c>'9'){if (c=='-')f=-1;c=getchar();}
while (c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-48;c=getchar();}
return x*f;
}

const int MAXN=150005;
int n,k,ans;
int f[MAXN];

inline int find(int x)
{
return f[x]==x?x:f[x]=find(f[x]);
}

int main()
{
for (int i=1;i<=3*n;i++) f[i]=i;
int id,x,y;
for (int i=1;i<=k;i++){
if ((x>n||y>n)&&++ans)continue;
if (id==1){
if ((find(x)==find(y+n)||find(x+n)==find(y))&&++ans)continue;
f[find(x)]=find(y);f[find(x+n)]=find(y+n);f[find(x+2*n)]=find(y+2*n);
}
else if (id==2){
if ((find(x)==find(y)||find(x)==find(y+2*n))&&++ans)continue;
f[find(x)]=find(y+n);f[find(x+2*n)]=find(y);f[find(x+n)]=find(y+2*n);
}
}
printf("%d\n",ans);
return 0;
}```

Followed by: