对拍
#include <bits/stdc++.h>
using namespace std;
// make 是数据生成器,其他的是两份代码
bool work()
{
system("make.exe > input.txt");
system("DFS.exe < input.txt > DFS.txt");
system("DP.exe < input.txt > DP.txt");
return !system("fc DP.txt DFS.txt");
}
int main()
{
for (int i = 0; i < 1000; i ++ )
{
if (!work()) {
break;
}
}
return 0;
}
数据生成器
生成一棵树
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<stack>
#include<string>
#include<random>
#include<iomanip>
#define yes puts("yes");
#define inf 0x3f3f3f3f
#define ll long long
#define linf 0x3f3f3f3f3f3f3f3f
#define ull unsigned long long
#define endl '\n'
#define int long long
#define rep(i,a,n) for(int i = a;i <= n;i++)
#define per(i,n,a) for(int i = n;i >= a;i--)
using namespace std;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x;}
typedef pair<int,int> PII;
const int MAXN =10 + 2e5 ,mod=1e9 + 7;
int fa[MAXN];
int root(int x) {
return fa[x] == x ? x : (fa[x] = root(fa[x]));
}
void solve()
{
const int MAX = 5;
int n = rnd(MAX) + 1;
cout << n << "\n";
int cnt = 0;
rep(i,0,n) fa[i] = i;
while(cnt < n - 1) {
int u = rnd(n),v = rnd(n);
u ++, v ++;
if(root(u) == root(v)) continue;
fa[root(u)] = root(v);
cout << u << " " << v << "\n";
cnt ++;
}
}
signed main()
{
// int T;cin>>T;
// while(T--)
solve();
return 0;
}