各种杂物

长如狗的程序头

/*
ID:wjp13241
PROG:
LANG:C++
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define dfo(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,x,e) for(int i=ls[x];i;i=e[i].next)
#define fil(x,t) memset(x,t,sizeof(x))
#define FILEIN(s) freopen(s,"r",stdin)
#define FILEOUT(s) freopen(s,"w",stdout)
#define STP system("pause")
#define min(x,y) x<y?x:y
#define max(x,y) x>y?x:y
#define MP(x,y) make_pair(x,y)
#define PuB(v,x) v.push_back(x)
#define PoB(v) v.pop_back()
#define ld long double
#define ll long long
#define db double
#define INF 0x3f3f3f3f
#define LIM 100000000
#define EPS 1e-4
#define N 100201
#define E N*20+1
#define L 21
using namespace std;

读入优化

inline ll read(){
    ll x=0,p=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if (ch=='-')p=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return x*p;
}

输出优化

inline void write(ll x){
    char ch[L]={};int i=0;
    if (x<0) putchar('-');
    do{ch[++i]='0'+x%10;}while (x/=10);
    while (i)putchar(ch[i--]);
    putchar('\n');
}

随机数

#include <ctime>
using namespace std;
inline int get(int x){return rand()%x;}
int main()
{
    srand((unsigned)time(NULL));
    int n=get(32767);
    return 0;
}

sublime设置

{
    "draw_white_space": "all",
    "bold_folder_labels": true,
    "color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
    "font_face": "roboto mono medium",
    "font_size": 12,
    "highlight_line": true,
    "highlight_modified_tabs": true,
    "ignored_packages":
    [
        "Vintage"
    ],
    "line_padding_bottom": 1,
    "line_padding_top": 1,
    "material_theme_tree_headings": true,
    "overlay_scroll_bars": "enabled",
    "theme": "Material-Theme.sublime-theme",
    "word_wrap": true
}

vimrc

set nu
set autoindent
set cindent
set smartindent
set guifont=roboto_mono_medium:h10:b:cDEFAULT
set ruler
syntax on
filetype on
inoremap ( ()<Esc>i
        inoremap [ []<Esc>i
        inoremap { {<CR>}<Esc>O
        autocmd Syntax html,vim inoremap < <lt>><Esc>i| inoremap > <c-r>=ClosePair('>')<CR>
        inoremap ) <c-r>=ClosePair(')')<CR>
        inoremap ] <c-r>=ClosePair(']')<CR>
        inoremap } <c-r>=CloseBracket()<CR>
        inoremap " <c-r>=QuoteDelim('"')<CR>
        inoremap ' <c-r>=QuoteDelim("'")<CR>

        function ClosePair(char)
     if getline('.')[col('.') - 1] == a:char
      return "\<Right>"
       else
        return a:char
         endif
         endf

         function CloseBracket()
     if match(getline(line('.') + 1), '\s*}') < 0
      return "\<CR>}"
       else
        return "\<Esc>j0f}a"
         endif
         endf

         function QuoteDelim(char)
     let line = getline('.')
      let col = col('.')
       if line[col - 2] == "\\"
        return a:char
         elseif line[col - 1] == a:char
          return "\<Right>"
           else
            return a:char.a:char."\<Esc>i"
         endif
         endf

win对拍

:loop
data.exe
std.exe
myp.exe
fc std.out myp.out
if errorlevel 1 goto end
goto loop
:end
pause

linux对拍

#!bin/bash
while true;
do
./data
./std
./myp
if diff std.out myp.out;then
echo AC
else
echo WA
exit 0
fi
done

C++对拍


终于还是学习了C++对拍的姿势,这样写可以比较时间而且win下和linux下都能跑,非常优秀

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <ctime>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

int main(void) {
    std:: ios:: sync_with_stdio(false);
    rep(i,1,100000) {
        printf("%d ",i);
        system("./data");
        double tt=clock();
        system("./std");
        std:: cout<<clock()-tt<<' ';
        tt=clock();
        system("./myp");
        std:: cout<<clock()-tt<<' ';
        if (system("diff std.out myp.out > NULL")==0) puts("AC");
        else {
            puts("WA");
            return 0;
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/jpwang8/article/details/53396928