这道题我码了1h
调错一上午 写的对拍程序贡献出来 想复杂一点的话可以改变n的大小。
往死里拍一定可以让你发现你的错误的!加油。
by chdy @ 2019-05-05 11:10:13
```
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<cstdlib>
using namespace std;
int n,m;
int a[1000];
int f[1000],cnt;
int getfather(int x){return x==f[x]?x:f[x]=getfather(f[x]);}
int main()
{
freopen("1.in","w",stdout);
srand(time(0));
n=rand()%5+2;
m=rand()%5+1;
cout<<n<<' '<<m<<endl;
for(int i=1;i<=n;++i)cout<<rand()%n+1<<' ';
cout<<endl;
for(int i=1;i<=n;++i)f[i]=i;
while(cnt<n-1)
{
int x=rand()%n+1;
int y=rand()%n+1;
int xx=getfather(x);
int yy=getfather(y);
if(xx==yy)continue;
f[xx]=yy;++cnt;
cout<<x<<' '<<y<<endl;
}
for(int i=1;i<=m;++i)
{
if(i&1)
{
cout<<"Q"<<endl;
int l=rand()%n+1;
int r=rand()%n+1;
cout<<l<<' '<<r<<' '<<endl;
}
else
{
cout<<"C"<<endl;
int l=rand()%n+1;
int r=rand()%n+1;
int z=rand()%1000000000+1;
cout<<l<<' '<<r<<' '<<z<<endl;
}
}
return 0;
}
```
by chdy @ 2019-05-05 11:10:53
@[chdy](/space/show?uid=59688) 十分感谢你的对拍!!终于找到Bug了!
by henuwxj @ 2019-05-14 15:23:36
@[chdy](/space/show?uid=59688) 终于过了,LCA比较相同颜色的时候那个查询写错了QAQ...
再次感谢dalao orz
by henuwxj @ 2019-05-14 15:42:28
@[henuwxj](/space/show?uid=123934) 没事,对拍程序很简单,关键是当时把我卡自闭了。。
by chdy @ 2019-05-14 17:00:55
@[chdy](/space/show?uid=59688)
谢谢你的对拍
by Tarsal @ 2019-06-16 11:07:07
万分感谢!!!
by xiaomo @ 2019-10-04 21:03:42