C++模板、.vimrc和一些Linux配置
C++模板
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(register int i=(l);i<=(r);++i)
#define repdo(i,l,r) for(register int i=(l);i>=(r);--i)
#define il inline
typedef double db;
typedef long long ll;
//---------------------------------------
int n;
int main(){
ios::sync_with_stdio(0),cin.tie(0);
return 0;
}
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
.vimrc - Linux(Ubuntu)
vimscript 的高亮看起来似乎有点奇怪, 应该是 "
注释的锅...
"base
set nu
set ruler
set mouse=a
set confirm "confirm for saving changes
set showcmd
set laststatus=2 "show status bar
set foldmethod=manual
set encoding=utf8
set fileencodings=ucs-bom,utf8,gb18030,gbk,big5,latin9
"colorscheme ron
"indent
set shiftwidth=4 tabstop=4 softtabstop=4
set cindent autoindent smartindent
"search
set ignorecase
set is hls
"auto
set autochdir
set autoread
"lang en_US.utf8 "set language
map <c-a> ggVG
imap <c-a> <esc><c-a>
map <c-v> "+p
imap <c-v> <esc><c-v>i<right>
vmap <c-c> "+y
vmap <c-x> "+d
imap <c-e> <esc><c-e>i<right>
imap <c-y> <esc><c-y>i<right>
inoremap ' ''<left>
inoremap " ""<left>
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
inoremap {<cr> {<cr>}<esc>O
vnoremap <tab> :s/^/<tab><cr>:noh<cr> "tab 缩进
map <f5> :w<cr>:!g++ % -o %<.exec -g3 -std=c++11 -Wall -Wextra && gdb %<.exec <cr>
map <f9> :w<cr>:!g++ % -o %<.exec -std=c++98 -Wall -Wextra && ./%<.exec <cr>
map <f10> :w<cr>:!g++ % -o %<.exec -O2 -std=c++11 -Wall -Wextra && ./%<.exec <cr>
map <f8> :w<cr>:!time ./%<.exec <cr>
.vimrc - WSL2
"base
set nu
set ruler
set mouse=a
set confirm "confirm for saving changes
set showcmd
set laststatus=2 "show status bar
set foldmethod=manual
set encoding=utf8
set fileencodings=ucs-bom,utf8,gb18030,gbk,big5,latin9
colorscheme skeletor
set cc=100
hi ColorColumn ctermbg=darkgrey
set cursorline
hi CursorLine ctermbg=89
"indent
set shiftwidth=4 tabstop=4 softtabstop=4
set cindent autoindent smartindent
"search
set ignorecase
set is hls
"auto
"set autochdir
set autoread
set path=.,/usr/include/**,/usr/local/include/**
"lang en_US.utf8 "set language
map <c-a> ggVG
imap <c-a> <esc><c-a>
map <c-v> "+p
imap <c-v> <esc><c-v>i<right>
vmap <c-v> d"+p
vmap <c-c> "+y
vmap <c-x> "+d
imap <c-e> <esc><c-e>i<right>
imap <c-y> <esc><c-y>i<right>
inoremap ' ''<left>
inoremap " ""<left>
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
inoremap {<cr> {<cr>}<esc>O
"tab 缩进
vnoremap <tab> :s/^/<tab><cr>:noh<cr>
map <f5> :w<cr>:!g++ % -o %<.exec -g3 -std=c++11 -Wall -Wextra && gdb %<.exec <cr>
map <f9> :w<cr>:!g++ % -o %<.exec -std=c++98 -Wall -Wextra && ./%<.exec <cr>
map <f10> :w<cr>:!g++ % -o %<.exec -O2 -Wall -Wextra && ./%<.exec <cr>
map <f8> :w<cr>:!time ./%<.exec <cr>
"au VimEnter * silent! !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
"au VimLeave * silent! !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Caps_Lock'
" WSL yank/paste support
let s:clip = '/mnt/c/Windows/System32/clip.exe' " change this path according to your mount point
if executable(s:clip)
augroup WSLYank
autocmd!
autocmd TextYankPost * if v:event.operator ==# 'y' | call system(s:clip, @0) | endif
augroup END
endif
nnoremap "+p :r !powershell.exe -Command "& {Get-Clipboard}"<Enter>
vnoremap "+p :r !powershell.exe -Command "& {Get-Clipboard}"<Enter>
.bashrc
# append at the end of ~/.bashrc
# edited by myself
alias rm='trash-put -v'
alias oi='sh ~/oi/base/new.sh'
alias mv='mv -bvi'
alias cp='cp -bvi'
alias ll='ls -AlhFb'
alias mkdir='mkdir -pv'
alias unzip936='unzip -O cp936'
# capslock <=> esc
# xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
# xmodmap -e 'clear Lock' -e 'keycode 0x9 = Caps_Lock' # not exactly sure it's right; but it works
new.sh
# ~/oi/code/base/new.sh
# command 'oi' : create a file as a copy of '~/oi/base/template.cpp'
cp -bvi ~/oi/code/base/template.cpp $1.cpp
echo "new"
vim $1.cpp
judge脚本
#!/bin/bash
# jud.sh
# 评测和提答
# check *.cpp with *.ans
for i in $(seq 1 20)
do
printf "Case #%d-----------------------------\n" $i
time ./$1.exec < "$1"$i.in > "$1"$i.out
diff -bs "$1"$i.out "$1"$i.ans
read -sn 1
printf "\n"
done
#!/bin/bash
# pia.sh
# 对拍
for i in $(seq 1 200)
do
./$1-gene.exec > "$1"$i.in
./$1-std.exec < "$1"$i.in > "$1"$i.ans
time ./$1.exec < "$1"$i.in > "$1"$i.out
diff -bs "$1"$i.out "$1"$i.ans
read -s -n 1
done
.gdbinit
位于 ~/.gdbinit
.
set max-value-size unlimited
其他
Ubuntu紫
RGB: (48,9,36)
0x300924
Cygwin
download:
https://cygwin.com/setup-x86.exe
https://cygwin.com/setup-x86_64.exe
source:
https://mirrors.tuna.tsinghua.edu.cn/cygwin
:q<cr>