从一开始的 NOI Linux 生活(基础篇)

· · 个人记录

编译:

g++ a.cpp -o  a -O2 -std=c++14 -Wall -Wextra -Wconversion -Wshadow

运行:

./a

测试添加:(-D_GLIBCXX_DEBUG -fsanitize=undefined -fsanitize=address)

无限栈(全局)

-ulimit -s unlimited

常用指令:

ls
ll
rm FILE
cd ..
cd DIRECTORY
pwd
python3
mkdir
time COMMAND
timeout TIME_LIMIT COMMAND
size FILE
usr/bin/time/ -v ./FILE

对拍:

clock_t a,b,mx;
int main()
{
    //system("g++ a.cpp -o a -O2");
    //system("g++ b.cpp -o b -O2");
    //system("g++ gen.cpp -o gen -O2");
    int tc=0;
    while(true)
    {
        ++tc;
        cerr << "test case "<<tc<<": ";
        system("./gen PARAMETER > in");
        system("./b < in > ans");
        a=clock();
        if(system("./a < in > out"))
        {/*RE*/}
        b=clock();
        if(system("diff out ans > judge"))
        {/*WA*/}
        mx=max(mx,b-a);
        if(mx>TIMELIMIT)
        {/*TLE*/}
        /*AC*/
    }
}