对着博客刷题目

https://blog.csdn.net/qq_29556211/article/category/7210425/2

知识点:
双指针
https://www.cnblogs.com/jianrenfang/p/6754595.html
https://blog.csdn.net/dormousenone/article/details/70504649
https://blog.csdn.net/zhelong3205/article/details/77970436
** https://blog.csdn.net/cpohui/article/details/79623828

https://blog.csdn.net/qq_26222859/article/details/61913990
https://www.bilibili.com/video/av8141430/

cf:
https://blog.csdn.net/sinat_35406909/article/details/80450320

比赛集合

比赛集合
https://blog.csdn.net/qq_29556211/article/details/80057837
https://blog.csdn.net/qq_29556211/article/details/70158165
https://blog.csdn.net/dxyinme/article/details/77923155
https://blog.csdn.net/u013029272/article/details/51492304
https://blog.csdn.net/lemonoil/article/details/78310347

对着博客专练

https://blog.csdn.net/huanghongxun/article/details/78761425
https://blog.csdn.net/z631681297/article/details/80307838

主题
最大独立集
https://blog.csdn.net/qq_21057881/article/details/50658753?locationNum=1&fps=1
https://www.cnblogs.com/a-clown/p/6698913.html
https://blog.csdn.net/duan_1998/article/details/78539800?locationNum=9&fps=1

https://www.cnblogs.com/neopenx/p/4006417.html
贪心好题
https://blog.csdn.net/just_sort/article/details/64905078

算法讲解
https://blog.csdn.net/qq_34374664/article/details/56015253
https://blog.csdn.net/qq_34374664/article/details/52230368
白话系列
https://blog.csdn.net/jarjingx/article/details/8521690

对拍

https://blog.csdn.net/Todobe/article/details/55505461

1.数据创建
datamaker.cpp:
#include <bits/stdc++.h>

using namespace std;  

typedef long long int ll;  

ll rget( ll a, ll b)  
{  
    return (rand() % (b - a) ) + a;//产生范围为 [a, b]的随机数  
}  

int main()  
{  
    srand( (unsigned int) time( NULL ));//以时间为随机种子  
    ll T = 100;  
    cout << T << endl;//T組样例  
    while(T--)  
    {  
            //数据生成部分具体根据题意写  

        }  
    return 0;  
}  

2.对拍脚本

[plain] view plain copy

#!/bin/bash  
rm data  
rm out1  
rm out2  

g++ datamaker.cpp -o datamaker  

#运行datamaker,将测试数据存入data文件  
./datamaker >> data  

#将data文件中数据输入要测试的程序,再输出到文件out1、out2  
cat data | ./Main >> out1  
cat data | ./ans >> out2  

#比较out1 out2  
if diff out1 out2; then  
printf "Accept\n"  
else  
echo WrongAnswer  
fi  

此脚本方便之处在于无需在源代码中添加freopen之类输入重定向即可实现数据输入输出,缺点暂时没发现。

////////////////////////////////////////////

上文脚本有缺陷… (脚本代码太low)

对拍脚本更新:

#!/bin/bash

./datamaker > data
./Main < data > out1
./Ans < data > out2
diff out1 out2

执行脚本后如果没输出,说明结果正确,如果有输出,输出表示的就是答案不匹配的行

FOR ACM OI

在Linux的shell脚本对拍命令

执行方法:在终端下,进入当前目录,输入”sh ./nick.sh”,(其中nick.sh为当前shell脚本名)

ubuntu14.04下实测成功

while true; do
./make>tmp.in #出数据
./tmp<tmp.in>tmp.out #被测程序
./tmp2<tmp.in>tmp2.out #正确(暴力)程序
if diff tmp.out tmp2.out; then #比较两个输出文件
printf AC #结果相同显示AC
else
echo WA #结果不同显示WA,并退出
#cat tmp.out tmp2.out
exit 0
fi #if的结束标志,与C语言相反,0为真
done # while的结束标志

#BY NICK WONG 2014-08-29
#在终端下,进入当前目录,输入”sh ./nick.sh”,(其中nick.sh为当前shell脚本名) ‘#’表示单行注释
#diff在两文件相同时返回空串

参考1:贴吧的讨论:http://tieba.baidu.com/p/1748233229

参考2:ACM OI windows对拍模板 (详细注释版)

@echo off  
:ac  

e-make>e.in  :出数据  
e-3<e.in>e.out    :被测程序  
e-2<e.in>e.out2   :暴力程序  
fc e.out e.out2  
:diff -q e.out e.out2 这句可以代替上一句  
if errorlevel=1 goto wa       
echo ac  
goto ac  

:wa  
echo wa  
:type e.out e.out2 :这句可有可无  
pause  

退出状态  
  此命令返回下列退出值:  
  0 未找到不同处。  
  1 找到不同处。  
  >1 发生错误。  


  脚本程序基于Python3.4,请先配置好环境。

[python] view plain copy

import os  

def run():  
    # 运行程序并输出结果  
    os.system('my.exe < in.txt > my.dat')  
    os.system('right.exe < in.txt > right.dat')  

def check():  
    # 逐行对比运行结果  
    my = open('my.dat', 'r')  
    right = open('right.dat', 'r')  
    log = open('log.txt', 'w')  
    log.write('-----------All Error-----------\n')  
    for (i, (a, b)) in enumerate(zip(my, right)):  
        if a != b:  
            log.write('line ' + str(i+1) + '\n')  
            log.write('---MY:' + a)  
            log.write('---AC:' + b)  

if __name__ == '__main__':  
    run()  
    check()  

in.txt——数据输入文件

my.exe—-你的程序

right.exe–AC的程序

my.dat—-你的程序的输出

right.dat–AC程序的输出

log.txt—-输出结果对比

1)产生任意范围的数
[cpp] view plain copy

#include<stdio.h>  
#include<stdlib.h>  
#include<string.h>  
#include<math.h>  
#include<time.h>  
int main( )  
{  
    //freopen( "1.in","r",stdin );  
    freopen("3.out","w",stdout );  
    srand( time( NULL ) );  
    int t = 99,n = 10 ;  
    while( n-- )  
    {  
           printf("%d\n",rand() % t );  
           }  
    return0;  
}  

2)产生int型随机数
[cpp] view plain copy

#include<stdio.h>  
#include<stdlib.h>  
#include<string.h>  
#include<math.h>  
#include<time.h>  
int main( )  
{  
    //freopen( "1.in","r",stdin );  
    //freopen( "3.out","w",stdout );  
    srand( time( NULL ) );  
    int t,n = 10 ;  
    while( n-- )  
    {  
           printf("%d\n",rand() );  
           }  
    return0;  
}  

3)产生随机小数
[cpp] view plain copy

#include<stdio.h>  
#include<stdlib.h>  
#include<string.h>  
#include<math.h>  
#include<time.h>  
int main( )  
{  
    //freopen( "1.in","r",stdin );  
    //freopen( "3.out","w",stdout );  
    srand( time( NULL ) );  
    int n = 10 ;  
    while( n-- )  
    {  
           printf("%.6lf\n",rand()*1.0 / 100 );  
           }  
    return0;  
}  

4)产生字符串

int main( )  
{  
    //freopen( "1.in","r",stdin );  
    freopen("3.out","w",stdout );  
    srand( time( NULL ) );  
    int t = 99,n = 10 ;  
    while( n-- )  
    {  
           printf("%c\n",rand() % 26 +'A');  
           }  
    return0;  
}  

Ubuntu下bash对拍

#!/bin/bash

fpc random
fpc a
fpc b

i=1
tot=10000000

while [ $i -le $tot ]
do
./random > data.in
./a < data.in > a.out
./b < data.in > b.out
if diff -b a.out b.out; then
echo -e “YES!!!”
else
echo -e “NO!!!”
break
fi
let i=i+1
done

第一次拍前要chmod +x pai.sh

刘汝佳的对拍脚本(改)

#!/bin/bash
g++ me.cpp -g -o me
g++ std.cpp -g -o std
while true; do
./rand > input.in
./std < input.in > std.out
./me < input.in > me.out
diff std.out me.out
if [ $? -ne 0 ] ; then
echo WA; break ;
fi ;
echo AC;
done

常用语法

开头必须用这个!!!

#!/bin/bash

然后一些命令可以直接用终端里的:

gdb me
g++ std.cpp -g -o std

重定向输入输出:

./std < input.in > std.out

输入就是 < ,指向可执行文件;输出就是 > ,从可执行文件出来

条件语句:

if 表达式; then
语句
fi 表达式 ;
语句

if后加空格,没有括号;条件后有分号“ ; ”。

循环语句:

while 条件; do
循环体
done

套就行。

显示:

echo 内容;

引号都不用加,直接就是字符串。(显示变量另说)

运行:

noilinux@ubuntu:~/Desktop$ chmod +x dp.sh
noilinux@ubuntu:~/Desktop$ ./dp.sh

成套比赛题解

https://blog.csdn.net/qq_29556211/article/details/78130052 +

2016-2017 ACM-ICPC, Asia Tsukuba Regional Contest
https://blog.csdn.net/sinat_32872703/article/details/72764671

https://blog.csdn.net/qwerty1125/article/details/78036449 +

2017-2018 ACM-ICPC, Asia Daejeon Regional Contest
http://blog.myungwoo.kr/121
https://www.cnblogs.com/skyette/p/8271006.html

http://www.cnblogs.com/flipped/p/6401218.html +

csdn 博客专题收割

https://blog.csdn.net/zhuanshunzhe/article/details/72758063
https://blog.csdn.net/fouzhe/article/category/6467108
https://blog.csdn.net/chenzhenyu123456/article/category/5585753
https://blog.csdn.net/black_miracle/article/details/70990707
https://blog.csdn.net/black_miracle/article/details/70990752
https://blog.csdn.net/Mitsuha_/article/details/79395066

线性基深入了解

https://blog.csdn.net/qwb492859377/article/details/52944803
https://blog.csdn.net/qwb492859377/article/details/52939589

置换群
https://blog.csdn.net/chenzhenyu123456/article/category/5585753
https://blog.csdn.net/qq_37383726/article/details/78598519

BZOJ资料合集 https://blog.csdn.net/CreationAugust/article/details/51205469