0%

我的NOI-Linux的使用指北

gedit的配置

gedit首选项

查看

显示行号
启用自动换行,避免在单词内换行
突出显示当前行,匹配的括号

编辑器

制表符宽度4,不使用空格代替,启用自动缩进
保存前备份,间隔10分钟

字体和颜色

Ubuntu Mono 13
Oblivion

插件

启用外部工具

外部工具

添加Compile

快捷键F4
保存当前文档
输入无,输出在下方面板
使用范围所有文档,C++

1
2
3
4
5
6
7
8
9
10
11
#!/bin/sh
fullname=$GEDIT_CURRENT_DOCUMENT_NAME
name=`echo $fullname | cut -d. -f1`
suffix=`echo $fullname | cut -d. -f2`
dir=$GEDIT_CURRENT_DOCUMENT_DIR
if [ $suffix="cpp" ]; then
if [ -f "./$name" ]; then
rm "./$name"
fi
g++ $fullname -o $name -O2 -Wall -lm
fi

添加Run

快捷键F5
保存无,输入无,输出在下方面板
使用范围所有文档,C++

1
2
3
4
5
6
7
8
#!/bin/sh
fullname=$GEDIT_CURRENT_DOCUMENT_NAME
name=`echo $fullname | cut -d. -f1`
suffix=`echo $fullname | cut -d. -f2`
dir=$GEDIT_CURRENT_DOCUMENT_DIR
if [ -f "$dir/$name" ]; then
gnome-terminal --hide-menubar --working-directory=$dir -- bash -c "ulimit -s unlimited; /usr/bin/time -f '\n%es %Us' \"$dir/$name\"; echo 'Press any key to return...'; read"
fi
报错解决:
(gnome-terminal:4874): GLib-GIO-CRITICAL **: g_setting_get: the format string may not contain '&' (key 'monospace-font-name' from schema 'org.gnome.desktop.interface'). This call will probably stop working with a future version of glib.
1
sudo gsettings set org.gnome.desktop.interface monospace-font-name 'Ubuntu Mono 13'

Sublime Text 3

虽然NOI Linux没有,但是THUWC有。

新建编译系统

找到 /opt/sublime_text/Packages/C++.sublime-package 里面的 C++ Single File.sublime-build,复制出来,新建编译系统

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -O2 -Wall -lm -std=c++11 && gnome-terminal --hide-menubar -- bash -c \"ulimit -s unlimited; /usr/bin/time -f '\n%es %Us' \"${file_path}/${file_base_name}\"; echo 'Press any key to return...'; read\" ",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",

"variants":
[
{
"name": "Compile Only",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -O2 -Wall -lm -std=c++11"
},
{
"name": "Run Only",
"shell_cmd": "gnome-terminal --hide-menubar -- bash -c \"ulimit -s unlimited; /usr/bin/time -f '\n%es %Us' \"${file_path}/${file_base_name}\"; echo 'Press any key to return...'; read\" "
}
]
}

顺便附带一个 Windows 版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -O2 -Wall -std=c++11 -Wl,--stack=1024000000 & start cmd /c \"\"${file_path}/${file_base_name}\" & pause \" ",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",

"variants":
[
{
"name": "Compile Only",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -O2 -Wall -std=c++11 -Wl,--stack=1024000000"
},
{
"name": "Run Only",
"shell_cmd": "start cmd /c \"\"${file_path}/${file_base_name}\" & pause \" "
}
]
}

保存为 C++_Competition.sublime-build

对拍及数据生成器

对拍

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<bits/stdc++.h>
using namespace std;
int main() {
while (1) {
system("bash -c './datamaker $RANDOM > testdata.in'");
system("./baoli < testdata.in > testdata.ans");
clock_t start=clock();
system("./mysolution < testdata.in > testdata.out");
clock_t stop=clock();
if (system("diff testdata.out testdata.ans")) {
printf("GG\n");
break;
}
printf("AC in %lfs\n",(double)(stop-start)/CLOCKS_PER_SEC);
}
return 0;
}

数据生成器

1
2
3
4
5
6
7
8
9
#include<bits/stdc++.h>
using namespace std;
int main(int argc,char *argv[]) {
if (argc>1) srand(time(NULL)%10000*atoi(argv[1]));
else srand(time(NULL));

........
return 0;
}