赠送数据生成器
查看原帖
赠送数据生成器
988040
qtanglani楼主2024/3/13 20:07
#include<iostream>
#include<time.h>
using namespace std;
int main()
{
    freopen("data.in","w",stdout);
    srand(time(0));
    cout<<3<<endl;
    for(int i=1;i<=3;i++)
    {
        int n=rand()%20+1;
        int m=rand()%40+1;
        cout<<n<<" "<<m<<endl;
        for(int j=2;j<=n;j++)
            cout<<j<<" "<<rand()%(j-1)+1<<endl;
        for(int j=1;j<=m;j++)
        {
            int op;
            op=rand()%2+1;
            if(op==1)
            {
                int u=rand()%n+1;
                int v=rand()%n+1;
                if(u==v)
                    v=(v+1)%n+1;
                cout<<op<<" "<<u<<" "<<v<<endl;
            }
            else
            {   
                int u=rand()%n+1;
                int v=rand()%n+1;
                if(u==v)
                    v=(v+1)%n+1;
                cout<<op<<" "<<u<<" "<<v<<endl;
            }
        }
    }
}
2024/3/13 20:07
加载中...