Hack
查看原帖
Hack
223298
do_while_true楼主2022/7/27 17:40

把第一篇题解贪心200遍的乱搞hack掉了

构造方法:一条很长的链,随机顺序输出边。

gen:

#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<random>
#include<assert.h>
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n';
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<ll,int>pli;
typedef pair<ll,ll>pll;
typedef vector<int>vi;
typedef vector<ll>vll;
typedef vector<pii>vpii;
template<typename T>T cmax(T &x, T y){return x=x>y?x:y;}
template<typename T>T cmin(T &x, T y){return x=x<y?x:y;}
template<typename T>
T &read(T &r){
	r=0;bool w=0;char ch=getchar();
	while(ch<'0'||ch>'9')w=ch=='-'?1:0,ch=getchar();
	while(ch>='0'&&ch<='9')r=r*10+(ch^48),ch=getchar();
	return r=w?-r:r;
}
template<typename T1,typename... T2>
void read(T1 &x, T2& ...y){ read(x); read(y...); }
const int N=100010;
mt19937 rnd(time(NULL)^(ull)(new char));
int n=100000,p[N];
vpii a;
signed main(){
	freopen("data.in","w",stdout);
	for(int i=1;i<=n;i++)p[i]=i;
	cout << n << ' ' << n-1 << '\n';
	for(int i=1;i<n;i++){
		a.pb(mp(p[i],p[i+1]));
	}
	shuffle(a.begin(),a.end(),rnd);
	for(auto x:a)cout << 2 << ' ' << x.fi << ' ' << x.se << '\n';
	return 0;
}

output:5000050000

顺便求管理通过一下我的题解

2022/7/27 17:40
加载中...