跳到正文

剪贴板

剪贴板 am5srkcq

原文
剪贴板信息

剪贴板信息

收录
更新

对拍

C++
#include<bits/stdc++.h>
#include<conio.h>
using namespace std;

char C[1000]="rand";
char A[1000]="my";
char B[1000]="std";

//kill
char KC[1000],KA[1000],KB[1000];
//operation
char I[1000];
char AO[1000];
char BO[1000];
char FC[1000];
//open
char OC[1000];
char OA[1000];
char OB[1000];
//time
clock_t IS,AS,BS;
clock_t IE,AE,BE;
//else
int T;
int WA;

int mode;

void _1()
{
	while(!kbhit())
	{
		printf("test %d\n",++T);
		IS=clock();
		system(I);
		IE=clock();
		printf("create over:%d ms\n",IE-IS);
		AS=clock();
		system(AO);
		AE=clock();
		printf("%s.exe over:%d ms\n",A,AE-AS);
		BS=clock();
		system(BO);
		BE=clock();
		printf("%s.exe over:%d ms\n",B,BE-BS);
		if(system(FC))
		{
			WA=1;
			break;
		}
	}
	if(WA)
	{
		system(OA);
		system(OB);
		system(OC);
	}
	WA=0;
}

void _2()
{

	while(!kbhit())
	{
		printf("test %d\n",++T);
		IS=clock();
		system(I);
		IE=clock();
		printf("create over:%d ms\n",IE-IS);
		AS=clock();
		system(AO);
		AE=clock();
		printf("%s.exe over:%d ms\n",A,AE-AS);
	}
}

int main()
{
	sprintf(KC,"taskkill /f /t /im %s.exe",C);
	sprintf(KA,"taskkill /f /t /im %s.exe",A);
	sprintf(KB,"taskkill /f /t /im %s.exe",B);
	sprintf(I,"%s.exe>%s.out",C,C);
	sprintf(AO,"%s.exe<%s.out>%s.out",A,C,A);
	sprintf(BO,"%s.exe<%s.out>%s.out",B,C,B);
	sprintf(FC,"fc %s.out %s.out",A,B);
	sprintf(OC,"start %s.out",C);
	sprintf(OA,"start %s.out",A);
	sprintf(OB,"start %s.out",B);
	system(KC),system(KA),system(KB);

	system("cls");
	printf("please enter the mode\n");
	printf("1: run with std\n");
	printf("2: run without std\n");
	scanf("%d",&mode);
	system("cls");

	switch(mode)
	{
		case 1:
			{
				_1();
				break;
			}
		case 2:
			{
				_2();
				break;
			}
	}


	sprintf(KC,"taskkill /f /t /im %s.exe",C);
	sprintf(KA,"taskkill /f /t /im %s.exe",A);
	sprintf(KB,"taskkill /f /t /im %s.exe",B);
	sprintf(I,"%s.exe>%s.out",C,C);
	sprintf(AO,"%s.exe<%s.out>%s.out",A,C,A);
	sprintf(BO,"%s.exe<%s.out>%s.out",B,C,B);
	sprintf(FC,"fc %s.out %s.out",A,B);
	sprintf(OC,"start %s.out",C);
	sprintf(OA,"start %s.out",A);
	sprintf(OB,"start %s.out",B);
	system(KC),system(KA),system(KB);

	return 0;
}

rand

C++
#include<bits/stdc++.h>
using namespace std;

#define ll long long

ll R(ll l,ll r)
{
	mt19937 rnd(rand()%10000);
	ll res=rnd()*(ll)1e8+rnd();
	if(l>r) swap(l,r);
	if(l<0&&r<0)
	{
		l=-l,r=-r,swap(l,r);
		return -(res%(r-l+1)+l);
	}
	else if(l<0&&r==0)
	{
		l=-l,swap(l,r);
		return -res%(r+1);
	}
	else if(l<0&&r>0)
	{
		int f=rnd()%2;
		if(f) return res%(r+1);
		else return -res%l-1;
	}
	else if(l==0&&r==0) return 0;
	else return res%(r-l+1)+l;
}

int Rfast(int l,int r)
{
  	return rand()%(r-l+1)+l;
}

int main()
{
	srand(time(0));
	return 0;
}