This repository has been archived by the owner on Dec 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See issue #2. I dont know why?????? Add chinese readme
- Loading branch information
Showing
4 changed files
with
186 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
# Codeforces Tool | ||
|
||
[](https://github.com/xalanq/cf-tool/releases) | ||
[](https://github.com/xalanq/cf-tool/releases) | ||
[](https://travis-ci.org/xalanq/cf-tool) | ||
[](https://goreportcard.com/report/github.com/xalanq/cf-tool) | ||
[](https://github.com/golang) | ||
[](https://raw.githubusercontent.com/xalanq/cf-tool/master/LICENSE) | ||
|
||
Codeforces Tool 是 [Codeforces](https://codeforces.com) 的命令行界面的工具。 | ||
|
||
这玩意儿挺快、挺小、挺强大,还跨平台哦。 | ||
|
||
## 特点 | ||
|
||
* 提交代码到某场比赛的某道题目 | ||
* 查看提交后的情况(动态刷新) | ||
* 列出某场比赛的所有题目的整体信息 | ||
* 并行地获取某场比赛所有题目(或者某道题)的样例 | ||
* 根据你事先准备好的模板代码,生成一份带有时间戳、作者等信息的代码 | ||
* 全自动测试样例是否通过,若有错还会给出对比信息 | ||
* 用默认的网页浏览器打开题目页面、榜单 | ||
* 不是黑白的命令行界面 | ||
|
||
欢迎大家一起完善这个工具呀,欢迎Pull requests。 | ||
|
||
 | ||
|
||
## 安装 | ||
|
||
你可以从[这里](https://github.com/xalanq/cf-tool/releases)直接下载一个可执行文件,直接用就好啦。 | ||
|
||
或者你可以把整个 repo 给 clone 下来,然后自己编译: | ||
|
||
```plain | ||
$ git clone https://github.com/xalanq/cf-tool | ||
$ cd cf-tool | ||
$ go build -ldflags "-s -w" cf.go | ||
``` | ||
|
||
## 使用方法 | ||
|
||
```plain | ||
Codeforces Tool (cf). https://github.com/xalanq/cf-tool | ||
首先你得用 "cf config login"、 "cf config add" 命令来配置一下 | ||
如果你想用本工具打比赛,那么最好用 "cf race 1111" 命令,其中 "1111" 是比赛的 id | ||
支持的命令: | ||
cf config (login | add | default) | ||
cf submit [<filename>] | ||
cf submit [(<contest-id> <problem-id>)] [<filename>] | ||
cf list [<contest-id>] | ||
cf parse <contest-id> [<problem-id>] | ||
cf gen [<alias>] | ||
cf test [<filename>] | ||
cf watch [<contest-id>] | ||
cf open [<contest-id>] [<problem-id>] | ||
cf stand [<contest-id>] | ||
cf race <contest-id> | ||
例子: | ||
cf config login 配置你的用户名和密码。 | ||
cf config add 添加一份模板。 | ||
cf config default 设置默认的模板。 | ||
cf submit 如果当前路径是 "<contest-id>/<problem-id>" 那 cf 会找到匹配某个模板的代码, | ||
然后提交到 <contest-id> 这场比赛的 <problem-id> 题目。 | ||
cf submit a.cpp | ||
cf submit 100 a | ||
cf submit 100 a a.cpp | ||
cf list 列出当前比赛的题目通过、时限等信息。 | ||
cf list 1119 | ||
cf parse 100 获取比赛 id 为 100 的所有题目的样例到文件夹 "./100/<problem-id>" 下。 | ||
cf parse 100 a 获取比赛 id 为 100 的题目 a 的样例到当前文件夹下。 | ||
cf gen 用默认的模板生成一份代码到当前文件夹下。 | ||
cf gen cpp 用名字为 "cpp" 的模板来生成一份代码到当前文件夹下。 | ||
cf test 对当前目录下符合条件的代码进行操作,并测试全部样例。 | ||
cf watch 查看自己在当前比赛的最后 10 次提交结果。 | ||
cf open 1136 a 用默认的浏览器打开比赛 id 为 1136 的题目 a。 | ||
cf open 1136 用默认的浏览器打开比赛 id 为 1136 的总览页面。 | ||
cf stand 用默认的浏览器当前比赛的榜单。 | ||
cf race 1136 如果比赛还未开始且进入倒计时,则该命令会倒计时。当倒计时完后,会自动执行 | ||
'cf open 1136 a', 'cf open 1136 b', ..., 'cf open 1136 e', 'cf parse 1136' | ||
这些命令 | ||
注意: | ||
<problem-id> 表示题目的 id,比如 "a" 或者 "A",不区分大小写。 | ||
<contest-id> 表示比赛 id,你可以从比赛链接找到。比如 "https://codeforces.com/contest/1119" | ||
这个链接就是 id 为 "1119" 的比赛。 | ||
<alias> 模板的名字。 | ||
储存的文件: | ||
cf 会保存数据到以下文件: | ||
"~/.cfconfig" 这是配置文件,包括用户名、加密后的密码等。 | ||
"~/.cfsession" 这是会话文件,包括 cookies、用户名等。 | ||
"~" 这个符号是系统当前用户的主文件夹。 | ||
模板: | ||
你可以在你的代码里插入一些标识符,当用 cf 生成代码的时候,标识符会按照以下规则替换: | ||
$%U%$ 用户名 | ||
$%Y%$ 年 (e.g. 2019) | ||
$%M%$ 月 (e.g. 04) | ||
$%D%$ 日 (e.g. 09) | ||
$%h%$ 时 (e.g. 08) | ||
$%m%$ 分 (e.g. 05) | ||
$%s%$ 秒 (e.g. 00) | ||
模板内的脚本: | ||
模板支持三个脚本命令,当使用 `cf test` 时会依次执行: | ||
- before_script (只会执行一次) | ||
- script (有多少个样例就会执行多少次) | ||
- after_script (只会执行一次) | ||
"before_script" 或者 "after_script" 你可以根据需要来设置,也可以设置为空。 | ||
不过 "script" 你必须要运行你的程序,通过标准 IO 来输入/输出数据(不用重定向), | ||
以便 cf 测试。 | ||
你在这些脚本命令里也能插入一些标识符,这些标识符会按照以下规则替换: | ||
$%path%$ 代码的路径 (不包括 $%full%$, 比如 "/home/xalanq/") | ||
$%full%$ 代码的文件名 (比如 "a.cpp") | ||
$%file%$ 代码的文件名 (不包括后缀,比如 "a") | ||
$%rand%$ 一个长度为 8 的随机字符串 (只包括 "a-z" "0-9" 范围内的字符) | ||
Options: | ||
-h --help | ||
--version | ||
``` | ||
|
||
## 模板例子 | ||
|
||
```cpp | ||
/* Generated by powerful Codeforces Tool | ||
* You can download the binary file in here https://github.com/xalanq/cf-tool | ||
* Author: $%U%$ | ||
* Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$ | ||
**/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
typedef long long ll; | ||
|
||
int main() { | ||
ios::sync_with_stdio(false); | ||
cin.tie(0); | ||
|
||
return 0; | ||
} | ||
``` | ||
|
||
## 配置文件例子 | ||
|
||
你可以将以下内容保存到 `~/.cfconfig` 里 (不过你需要将 `path` 替换成你自己的路径) | ||
|
||
```json | ||
{ | ||
"username": "", | ||
"password": "", | ||
"template": [ | ||
{ | ||
"alias": "cpp", | ||
"lang": "42", | ||
"path": "C:\\develop\\template\\cf.cpp", | ||
"suffix": [ | ||
"cxx", | ||
"cc", | ||
"cpp" | ||
], | ||
"before_script": "g++ $%full%$ -o $%file%$.exe -std=c++11 -O2", | ||
"script": "./$%file%$.exe", | ||
"after_script": "" | ||
} | ||
], | ||
"default": 0 | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters