文件操作
freopen("xx.in","r",stdin);
freopen("xx.out","w",stdout);
对拍
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int err=0,T=0;
while(err!=1)
{
T++;
system("data");
system("bl");
system("zj");
error=system("fc bl.out zj.out");
while(clock()<T*1000);
}
}
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
using namespace std;
using namespace std;
int main()
{
freopen("data.in","w",stdout);
srand(time(0));
}
读入、输出优化
int read(){
char c=getchar();int x=0,f=1;
while(c>'9'||c<'0') {
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9') x=(x*10)+c-48,c=getchar();
return x*f;
}
inline void out(int x)
{
if(x>9) out(x/10);
putchar(x%10+'0');
putchar(32);
}
宏定义
#define M 100005
#define P 1000000007
#define INF 0x3f3f3f3f
#define INF INT_MAX
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>
#define MP(a,b) make_pair(a,b)
const double eps=1e-9;
const double pi=acos(-1);
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
头文件模板
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <vector>
#include <list>
简易版计时器
int start = clock();
//do_STH
printf("%.3lf\n",double(clock()-start)/CLOCKS_PER_SEC);