Skip to content
This repository was archived by the owner on May 21, 2020. It is now read-only.

Commit c6f9af2

Browse files
committed
(add ?) support to other OJ
1 parent a1dbe94 commit c6f9af2

File tree

7 files changed

+49
-24
lines changed

7 files changed

+49
-24
lines changed

GUIDEBOOK.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
`compileCommand`:编译命令,提供 `<path>` 表示源代码路径(不含 `.cpp`,不带引号,为了防止路径中含空格需要在 `<path>` 两端加上引号)。输出文件(`-o`)应为 `<path>.exe`
3030

31-
`unZIPCommand `:解压命令,提供 `<ZIPpath>` 表示zip 路径(包含 `.zip`,带引号,无需再加引号),`<unZIPpath>` 表示解压路径(带引号)。注意设置环境变量,确保自己在 cmd 中可以使用填入的命令下载。
31+
`unZIPCommand `:解压命令,提供 `<path>` 表示 `data` 文件夹路径(不带引号,绝对路径),`<id>` 表示题目编号。注意设置环境变量,确保自己在 cmd 中可以使用填入的命令下载。
3232

3333
`downloadCommand `: 用于自动下载数据,提供 `<id>` 表示题目 id,`<path>` 表示保存路径(不含保存的文件名 ,带引号)。注意设置环境变量,确保自己在 cmd 中可以使用填入的命令解压。
3434

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ BZOJ Local Judge 计划为 OIer 提供一个完整、便捷的 BZOJ 离线题库
1212

1313
如果你需要一个既简洁又通用的评测姬,可以使用 icey。
1414

15-
如果你需要一个便捷的 BZOJ 刷题平台,使用本项目就对了。
15+
如果你需要一个便捷的 OJ 刷题平台,使用本项目就对了。
1616

1717
## Getting Started
1818

@@ -56,6 +56,17 @@ Q:你这个东西并不便捷啊。
5656

5757
A:您好,只要花上不到五分钟配置一下,再熟悉一下命令,应该就足够方便了。尤其是没网的时候,比其它本地测评软件应该方便得多。如果真的遇到了什么问题,或者是有什么建议,欢迎在 [Issues](https://github.com/ouuan/BZOJLocalJudge/issues) 中提出。
5858

59+
## 应用于其它 OJ ?
60+
61+
把 BZOJ 题面删掉(或者放着不管),然后改一下 `config.ini`,就可以用于其它 OJ 了。
62+
63+
Example:([LOJ](https://loj.ac/)
64+
65+
```
66+
unZIPCommand WinRAR x "<path>\<id>.zip" "<path>\<id>\"
67+
downloadCommand IDMan /n /d https://loj.ac/problem/<id>/testdata/download /p <path> /f <id>.zip
68+
```
69+
5970
## 参考 / 使用的一些项目
6071

6172
[Ruanxingzhi / bzojch](https://github.com/Ruanxingzhi/bzojch)[应该是允许他人使用的](https://github.com/Ruanxingzhi/bzojch/issues/2)

config.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defaultTimeLimit 3000
22
defaultMemoryLimit 512
33
compileCommand g++ "<path>.cpp" -o "<path>" -O2 -std=c++11 -Wl,--stack=536870912
4-
unZIPCommand WinRAR x <ZIPpath> <unZIPpath>
4+
unZIPCommand WinRAR x "<path>\<id>.zip" "<path>\"
55
downloadCommand IDMan /n /d https://darkbzoj.tk/data/<id>.zip /p <path>

judge.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// judge <problemid> [timeLimit [memoryLimit [checkerPath]]]
22

33
#include <algorithm>
4+
#include <windows.h>
45
#include <direct.h>
56
#include <fstream>
67
#include <cstdlib>
@@ -16,7 +17,7 @@ string quote(const string & s)
1617
return "\"" + s + "\"";
1718
}
1819

19-
void unzip(const string & ZIPpath, const string & unZIPpath)
20+
void unzip(const string & id, const string & path)
2021
{
2122
ifstream config("config.ini");
2223
string command;
@@ -25,17 +26,17 @@ void unzip(const string & ZIPpath, const string & unZIPpath)
2526
getline(config, command);
2627
getline(config, command, ' ');
2728
getline(config, command);
28-
int p = command.find("<ZIPpath>");
29+
int p = command.find("<id>");
2930
while (p < command.size())
3031
{
31-
command.replace(p, 9, ZIPpath);
32-
p = command.find("<ZIPpath>");
32+
command.replace(p, 4, id);
33+
p = command.find("<id>");
3334
}
34-
p = command.find("<unZIPpath>");
35+
p = command.find("<path>");
3536
while (p < command.size())
3637
{
37-
command.replace(p, 11, unZIPpath);
38-
p = command.find("<unZIPpath>");
38+
command.replace(p, 6, path);
39+
p = command.find("<path>");
3940
}
4041
system(command.c_str());
4142
}
@@ -132,8 +133,9 @@ int main(int argc, char* argv[])
132133
download(problemid, quote(pwd + "\\data"));
133134
}
134135
while (_access(path.c_str(), 0) == -1);
136+
Sleep(100);
135137
puts("unzipping...");
136-
unzip(quote(path), quote(pwd + "\\data"));
138+
unzip(problemid, pwd + "\\data");
137139
while (_access((pwd + "\\data\\" + problemid).c_str(), 0) == -1);
138140
}
139141

opencpp.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,20 @@ int main(int argc, char* argv[])
2222

2323
string problemid = argv[1];
2424
string pwd = getcwd(NULL, 0);
25-
string path = pwd + "\\problems\\" + problemid + "\\" + problemid + ".cpp";
26-
25+
string path = pwd + "\\problems\\" + problemid;
26+
27+
if (_access(path.c_str(), 0) == -1)
28+
{
29+
system(("mkdir " + quote(path)).c_str());
30+
}
31+
32+
path += "\\" + problemid + ".cpp";
33+
2734
if (_access(path.c_str(), 0) == -1)
2835
{
2936
system(("copy template.cpp " + quote(path)).c_str());
3037
}
31-
38+
3239
system(("start \"\" " + quote(path)).c_str());
3340

3441
return 0;

opendata.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// opendata <problemid>
22

3+
#include <windows.h>
34
#include <direct.h>
45
#include <fstream>
56
#include <cstdlib>
@@ -13,7 +14,7 @@ string quote(const string & s)
1314
return "\"" + s + "\"";
1415
}
1516

16-
void unzip(const string & ZIPpath, const string & unZIPpath)
17+
void unzip(const string & id, const string & path)
1718
{
1819
ifstream config("config.ini");
1920
string command;
@@ -22,17 +23,17 @@ void unzip(const string & ZIPpath, const string & unZIPpath)
2223
getline(config, command);
2324
getline(config, command, ' ');
2425
getline(config, command);
25-
int p = command.find("<ZIPpath>");
26+
int p = command.find("<id>");
2627
while (p < command.size())
2728
{
28-
command.replace(p, 9, ZIPpath);
29-
p = command.find("<ZIPpath>");
29+
command.replace(p, 4, id);
30+
p = command.find("<id>");
3031
}
31-
p = command.find("<unZIPpath>");
32+
p = command.find("<path>");
3233
while (p < command.size())
3334
{
34-
command.replace(p, 11, unZIPpath);
35-
p = command.find("<unZIPpath>");
35+
command.replace(p, 6, path);
36+
p = command.find("<path>");
3637
}
3738
system(command.c_str());
3839
}
@@ -80,11 +81,12 @@ int main(int argc, char* argv[])
8081
if (_access(path.c_str(), 0) == -1)
8182
{
8283
puts("downloading...");
83-
download(problemid, quote(pwd + "\\data"));
84+
download(problemid, pwd + "\\data");
8485
}
8586
while (_access(path.c_str(), 0) == -1);
87+
Sleep(100);
8688
puts("unzipping...");
87-
unzip(quote(path), quote(pwd + "\\data"));
89+
unzip(problemid, pwd + "\\data");
8890
while (_access((pwd + "\\data\\" + problemid).c_str(), 0) == -1);
8991
}
9092
system(("start \"\" " + quote(pwd + "\\data\\" + problemid)).c_str());

opendir.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ int main(int argc, char* argv[])
2121

2222
string problemid = argv[1];
2323
string pwd = getcwd(NULL, 0);
24+
string path = quote(pwd + "\\problems\\" + problemid);
2425

25-
system(("start \"\" " + quote(pwd + "\\problems\\" + problemid)).c_str());
26+
if (_access(path.c_str(), 0) == -1) system(("mkdir " + path).c_str());
27+
28+
system(("start \"\" " + path).c_str());
2629

2730
return 0;
2831
}

0 commit comments

Comments
 (0)