【置顶】电脑操作知识备忘

电脑操作知识备忘

编译

-Wall
开启提示

-std=c++11等

-O2
一定要大写……

-m32
32位程序,配合gdb32

-Wl,–stack=SIZE
扩栈

gdb

查看调用参数
info args

查看局部变量
info locals

查看函数栈
bt

每步操作都显示变量值
display

frame xxx
配合bt,跳转

linux下对拍

while true; do

if diff a.out a.ans; then printf AC
else exit 0
fi
done

卡常

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
%:pragma GCC optimize("Ofast")
%:pragma GCC optimize("inline")
%:pragma GCC optimize("-fgcse")
%:pragma GCC optimize("-fgcse-lm")
%:pragma GCC optimize("-fipa-sra")
%:pragma GCC optimize("-ftree-pre")
%:pragma GCC optimize("-ftree-vrp")
%:pragma GCC optimize("-fpeephole2")
%:pragma GCC optimize("-ffast-math")
%:pragma GCC optimize("-fsched-spec")
%:pragma GCC optimize("unroll-loops")
%:pragma GCC optimize("-falign-jumps")
%:pragma GCC optimize("-falign-loops")
%:pragma GCC optimize("-falign-labels")
%:pragma GCC optimize("-fdevirtualize")
%:pragma GCC optimize("-fcaller-saves")
%:pragma GCC optimize("-fcrossjumping")
%:pragma GCC optimize("-fthread-jumps")
%:pragma GCC optimize("-funroll-loops")
%:pragma GCC optimize("-fwhole-program")
%:pragma GCC optimize("-freorder-blocks")
%:pragma GCC optimize("-fschedule-insns")
%:pragma GCC optimize("inline-functions")
%:pragma GCC optimize("-ftree-tail-merge")
%:pragma GCC optimize("-fschedule-insns2")
%:pragma GCC optimize("-fstrict-aliasing")
%:pragma GCC optimize("-fstrict-overflow")
%:pragma GCC optimize("-falign-functions")
%:pragma GCC optimize("-fcse-skip-blocks")
%:pragma GCC optimize("-fcse-follow-jumps")
%:pragma GCC optimize("-fsched-interblock")
%:pragma GCC optimize("-fpartial-inlining")
%:pragma GCC optimize("no-stack-protector")
%:pragma GCC optimize("-freorder-functions")
%:pragma GCC optimize("-findirect-inlining")
%:pragma GCC optimize("-fhoist-adjacent-loads")
%:pragma GCC optimize("-frerun-cse-after-loop")
%:pragma GCC optimize("inline-small-functions")
%:pragma GCC optimize("-finline-small-functions")
%:pragma GCC optimize("-ftree-switch-conversion")
%:pragma GCC optimize("-foptimize-sibling-calls")
%:pragma GCC optimize("-fexpensive-optimizations")
%:pragma GCC optimize("-funsafe-loop-optimizations")
%:pragma GCC optimize("inline-functions-called-once")
%:pragma GCC optimize("-fdelete-null-pointer-checks")

SPJ板子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FILE *in, *stand, *out, *score, *report;
template<typename T>
string tostr(const T& v)
{
stringstream ss;
ss << v;
return ss.str();
}
/*
* argv[1]:输入
* argv[2]:选手输出
* argv[3]:标准输出
* argv[4]:单个测试点分值
* argv[5]:输出最终得分
* argv[6]:输出错误报告
*/
int main(int argc,char*argv[])
{
in = fopen(argv[1],"r");
out = fopen(argv[2],"r");
stand = fopen(argv[3],"r");
score = fopen(argv[5], "w");
report = fopen(argv[6], "w");
int n;fscanf(in,"%d",&n);
int cnt=0;bool bk=0;
for(int i=1;i<=n;i++)
{
double a,b;
fscanf(stand,"%lf\n",&a);
fscanf(out,"%lf\n",&b);
if(a*2<b or b*2<a)
{
cnt++;
if(cnt==11)
{
fprintf(score,"0");
fprintf(report, ("expected: "+tostr(a)+", found: "+tostr(b)+", line: "+tostr(i)+" (11th error)").c_str() );
bk=1;break;
}
}
}
if(!bk) fprintf(score,"%s",argv[4]),fprintf(report,"Good job");
}

数据改名器板子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
template<typename T>
string tostr(const T& v)
{
stringstream ss;
ss << v;
return ss.str();
}
int main(int argc,char*argv[])
{
for(int i=1;i<=55;i++)
{
string now;
if(i<=9) now="0"+tostr(i);
else now=tostr(i);
string cmd="ren "+now+".a"+" "+now+".out";
system(cmd.c_str());
//cout<<cmd<<endl;
}
}

本文基于 知识共享署名-相同方式共享 4.0 国际许可协议发布
本文地址:http://zory.ink/posts/7de4.html
转载请注明出处,谢谢!