跳到正文

Roger1220

1046003

苍山负雪,明烛天南

在洛谷打开
资料、奖项与版本

资料

编号
1046003
抓取

快速读入模版:

C++
inline ll /* __int128 */ read() {

	ll /* __int128 */ x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	return x * f;
}

快速读出模版:

C++
inline/*如果是__int128则可以不写inline*/ void out(int /* __int128 */ n){
	if(n<0){
		putchar('-');
		n=-n;
	}
	if(n>=10){
		out(n/10);
	}
	putchar(n%10+'0');
}

加快输入速度:

C++
 std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

迭代器代码:

C++
#defing IT set<int>::iterator

//其中“int”可以改为任何数据结构
//然后将文件中的auto改为IT

省事的方法:

C++
//1.
#define ll long long //宏定义
typedef long long ll; //字符

(将本行代码以后的所有ll替换为long long)

Debug的方法:

C++
#define Debug
//在代码开头

#ifdef Debug
//中间写要Debug的代码
#endef Debug

命令行选项:

C++
-std=c++14 -std=c11 -O2 -Wall

对拍代码:

C++
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main(){
    int i;
    for(i = 1;;i++){
        printf("The result of No. %d Case is:  " , i);
        //因为这里要用exe文件,所以对拍的两个代码需要先运行生成一个exe
        system("data.exe");
        system("std.exe");
        system("test.exe");
        if(system("fc std.out test.out")){
            printf("Wrong Answer\n");
            return 0;
        }else{
            printf("Accepted\n");
        }
        Sleep(1);
    }
    return 0;
}

生成样例的代码(如果题目中有足够的样例则可以不用):

C++
#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("data.in" , "w" , stdout);
    srand( (unsigned int) time( NULL ));

    //这里前面是必须打的
    
    int n = rand() % 20;
    //获取小于等于20的随机数
    printf("%d\n" , n);
    for(int i = 1;i <= n;i++){
        printf("%d" , rand()%20 + 50);
    }
    //中间这部分根据样例输入而定
    
    //后面也是必须打的
    
    fclose(stdout);

    
    return 0;
}

还没有收录这位用户的文章。