对拍
off
:loop
data
right
me
fc me.out right.out
if not errorlevel 1 goto loop
pause
goto loop
c++优化开关(O2,O3)
\\全局
#pragma GCC opitmize("O3")
#pragma G++ opitmize("O3")
\\过程
__attribute__((optimize("-O3")))
对拍(c++程序版)
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;
int main()
{
for (int i=1;i<=100000;i++)
{
printf("%d ",i);
system("data"); //数据
double tt=clock();
system("AC"); //正解,暴力
cout<<clock()-tt<<' ';
tt=clock();
system("me"); //要拍的程序
cout<<clock()-tt<<' ';
if (system("fc me.out AC.out > NULL")==0) puts("AC");
else {puts("WA"); return 0;}
}
return 0;
}
随机数据
srand((unsigned)time(NULL));
n=rand()%P;
手工栈代码
交到题库上未必能过编译,但可以在本地调试的时候用到。直接加在main()函数里面即可。
int size = 256 << 20; // 256MB
char *p = (char*)malloc(size) + size;
__asm__("movl %0, %%esp\n" :: "r"(p));