怎么有人从调不出来题变成调不出来 gen 呢?
所以写完放这里了,造福后人。
#include<bits/stdc++.h>
#define il inline
using namespace std;
il int read()
{
int xr=0,F=1; char cr;
while(cr=getchar(),cr<'0'||cr>'9') if(cr=='-') F=-1;
while(cr>='0'&&cr<='9')
xr=(xr<<3)+(xr<<1)+(cr^48),cr=getchar();
return xr*F;
}
const int N=1005;
int n,m,t,x,y,mp[N][N],vis[N][N];
struct node{int a,b,c,d;} q[N];
#define pii pair<int,int>
pii b[N*N];
int main()
{
srand(time(0)^random_device()());
x=100,y=100,t=80,m=100,n=1000; // x,y 网格的大小 t 围栏数 m 花的数量 n 牛的数量
// cout<<t<<endl;
assert(m+n<=x*y);
for(int i=1;i<=t;i++)
{
for(int l=1;l<=x;l++) for(int r=l;r<=x;r++) vis[l][r]=0;
int tot=0;
while("qwq")
{
int a=rand()%x+1,c=rand()%x+1;
if(a>c) swap(a,c);
while(vis[a][c]) {c++;if(c>x) a++,c=a;if(a>x) a=1,c=1;}
int cnt=0;
for(int l=1;l<=y;l++)
for(int r=l;r<=y;r++)
{
bool flag=1;
for(int j=1;j<i;j++)
{
if(q[j].c<a-1) continue;
if(q[j].a>c+1) continue;
if(q[j].b>r+1) continue;
if(q[j].d<l-1) continue;
flag=0;
if(q[i].c>c&&q[i].a<a&&q[i].b<l&&q[i].d>r) flag=1;
if(q[i].c<c&&q[i].a>a&&q[i].b>l&&q[i].d<r) flag=1;
}
if(flag) b[++cnt]=pii(l,r);
}
if(cnt)
{
int rnd=rand()%cnt+1;
q[i]={a,b[rnd].first,c,b[rnd].second}; break;
}
else {vis[a][c]=1,tot++;if(tot>=x*(x+1)/2) {t=i-1;break;}}
// else cerr<<"failed "<<i<<" "<<a<<" "<<c<<endl;
}
if(!q[i].a) break;
}
cout<<t<<endl;
for(int i=1;i<=t;i++)
{
cout<<q[i].a<<" "<<q[i].b<<" "<<q[i].c<<" "<<q[i].d<<endl;
}
cout<<m<<endl;
for(int i=1;i<=m;i++)
{
int xx=rand()%x+1,yy=rand()%y+1;
while(mp[xx][yy]) {yy++;if(yy>y) yy=1,xx++; if(xx>x) xx=1,yy=1;}
cout<<xx<<" "<<yy<<endl;
mp[xx][yy]=1;
}
cout<<n<<endl;
for(int i=1;i<=n;i++)
{
int xx=rand()%x+1,yy=rand()%y+1;
while(mp[xx][yy]) {yy++;if(yy>y) yy=1,xx++; if(xx>x) xx=1,yy=1;}
cout<<xx<<" "<<yy<<endl;
mp[xx][yy]=1;
}
return 0;
}