各种杂物

长如狗的程序头

/*
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;
}

gdb调试命令


晚年更博系列
格式:命令/缩写:作用,用法

run/r:没啥好说的
quit/q:没啥好说的
print/p:没啥好说的
break/b:设置断点 ,举例:break 45
whatis:显示变量类型 ,举例:whatis p
finish:运行直到当前过程结束 ,举例:finish
continue:跳至下一个断点 ,举例:continue
call:运行某一函数,举例 :call read()
set variable:变量赋值

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值