judge_system 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/compile_systems/c_system.cpp +11 -5
- data/lib/compile_systems/cpp_system.cpp +10 -4
- data/lib/compile_systems/java_system.cpp +59 -4
- data/lib/compile_systems/rb_system.cpp +9 -3
- data/lib/judge_system.rb +11 -9
- data/lib/judge_system/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0edbafdf0e837695223831d01c6a4046986dc9cb
|
4
|
+
data.tar.gz: 02c889a7d4545587dbb50a66bff4b3bb591cd83b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e68cef4d56cde0355d253262834d303df0b7285b4ce5ce104f171fdc31dfe9672ffddf1dd4d82ae8e0f56bf6275f613957c46445b5b1255ad749b27a6f8cff1b
|
7
|
+
data.tar.gz: 8412483c9cb7b206e155feb45bba324eb2c2372a88da4b2b50f520d57be696506fe841691b08472006575f1dc56df4ed64ae7be3e4e17541ed7684f313660c0a
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ $ gem install judge_system
|
|
27
27
|
```ruby
|
28
28
|
require 'judge_system'
|
29
29
|
|
30
|
-
JudgeSystem.judge_result lang(string text), code(string text), answer(string text),
|
30
|
+
JudgeSystem.judge_result lang: (string text), code: (string text), answer: (string text), stdin: (string text), time: (num sec)
|
31
31
|
|
32
32
|
#Lang is the extension of languages (example: c is 'c', c++ is 'cpp', ruby is 'rb', java is 'java').
|
33
33
|
#You can't use more than 1M byte code, input, answer.
|
@@ -39,10 +39,10 @@ example
|
|
39
39
|
```ruby
|
40
40
|
require 'judge_system'
|
41
41
|
|
42
|
-
p JudgeSystem.judge_result 'rb', "n = gets.to_i\nputs n", "1\n", "1\n", 5 #=> 'AC'
|
43
|
-
p JudgeSystem.judge_result 'rb', "n = gets.to_i\nputs n", "1\n", "2\n", 5 #=> 'WA'
|
44
|
-
p JudgeSystem.judge_result 'rb', "n = gets.to_i\nputs n", "1\n", "\n", 0.001 #=> 'TLE'
|
45
|
-
p JudgeSystem.judge_result 'c', "n = gets.to_i\nputs n", "1\n", "1\n", 5 #=> 'RE'
|
42
|
+
p JudgeSystem.judge_result lang: 'rb', code: "n = gets.to_i\nputs n", answer: "1\n", stdin: "1\n", time: 5 #=> 'AC'
|
43
|
+
p JudgeSystem.judge_result lang: 'rb', code: "n = gets.to_i\nputs n", answer: "1\n", stdin: "2\n", time: 5 #=> 'WA'
|
44
|
+
p JudgeSystem.judge_result lang: 'rb', code: "n = gets.to_i\nputs n", answer: "1\n", stdin: "\n", time: 0.001 #=> 'TLE'
|
45
|
+
p JudgeSystem.judge_result lang: 'c', code: "n = gets.to_i\nputs n", answer: "1\n", stdin: "1\n", time: 5 #=> 'RE'
|
46
46
|
```
|
47
47
|
|
48
48
|
|
@@ -2,22 +2,28 @@
|
|
2
2
|
#include <fstream>
|
3
3
|
using namespace std;
|
4
4
|
|
5
|
+
char command[1024];
|
6
|
+
|
5
7
|
int main(int argc, char const *argv[])
|
6
8
|
{
|
7
9
|
ofstream ofs;
|
8
|
-
ofs.open("
|
10
|
+
ofs.open("main.c",ios::binary);
|
9
11
|
string buf;
|
12
|
+
string splitter="<$><*><$>";
|
13
|
+
string time;
|
10
14
|
while(getline(cin,buf)){
|
11
|
-
if(buf==
|
15
|
+
if(buf==splitter)break;
|
12
16
|
ofs<<buf<<endl;
|
13
17
|
}
|
14
18
|
ofs.close();
|
15
19
|
ofs.open("test.in",ios::binary);
|
16
20
|
while(getline(cin,buf)){
|
21
|
+
if(buf==splitter)break;
|
17
22
|
ofs<<buf<<endl;
|
18
23
|
}
|
19
24
|
ofs.close();
|
20
|
-
|
21
|
-
|
25
|
+
cin>>time;
|
26
|
+
system("/opt/wandbox/gcc-head/bin/gcc main.c -o main -O2");
|
27
|
+
system(("timeout -s 9 " + time + " ./main < test.in").c_str());
|
22
28
|
return 0;
|
23
|
-
}
|
29
|
+
}
|
@@ -2,22 +2,28 @@
|
|
2
2
|
#include <fstream>
|
3
3
|
using namespace std;
|
4
4
|
|
5
|
+
char command[1024];
|
6
|
+
|
5
7
|
int main(int argc, char const *argv[])
|
6
8
|
{
|
7
9
|
ofstream ofs;
|
8
|
-
ofs.open("
|
10
|
+
ofs.open("main.cpp",ios::binary);
|
9
11
|
string buf;
|
12
|
+
string splitter="<$><*><$>";
|
13
|
+
string time;
|
10
14
|
while(getline(cin,buf)){
|
11
|
-
if(buf==
|
15
|
+
if(buf==splitter)break;
|
12
16
|
ofs<<buf<<endl;
|
13
17
|
}
|
14
18
|
ofs.close();
|
15
19
|
ofs.open("test.in",ios::binary);
|
16
20
|
while(getline(cin,buf)){
|
21
|
+
if(buf==splitter)break;
|
17
22
|
ofs<<buf<<endl;
|
18
23
|
}
|
19
24
|
ofs.close();
|
20
|
-
|
21
|
-
system("/
|
25
|
+
cin>>time;
|
26
|
+
system("/opt/wandbox/gcc-head/bin/g++ main.cpp -o main -O2");
|
27
|
+
system(("timeout -s 9 " + time + " ./main < test.in").c_str());
|
22
28
|
return 0;
|
23
29
|
}
|
@@ -5,7 +5,7 @@ using namespace std;
|
|
5
5
|
int main(int argc, char const *argv[])
|
6
6
|
{
|
7
7
|
ofstream ofs;
|
8
|
-
ofs.open("
|
8
|
+
ofs.open("Main.java",ios::binary);
|
9
9
|
string buf;
|
10
10
|
while(getline(cin,buf)){
|
11
11
|
if(buf=="<$><*><$><*><$><*><$><*><$><*><$><*><$>")break;
|
@@ -17,7 +17,62 @@ int main(int argc, char const *argv[])
|
|
17
17
|
ofs<<buf<<endl;
|
18
18
|
}
|
19
19
|
ofs.close();
|
20
|
-
system("/opt/wandbox/openjdk-head/bin/javac
|
21
|
-
system("/usr/bin/time -f '%U' /opt/wandbox/openjdk-head/bin/java
|
20
|
+
system("/opt/wandbox/openjdk-head/bin/javac Main.java");
|
21
|
+
system("/usr/bin/time -f '%U' /opt/wandbox/openjdk-head/bin/java Main < test.in");
|
22
22
|
return 0;
|
23
|
-
}
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
/*import java.util.*;
|
29
|
+
import java.io.*;
|
30
|
+
class Career{
|
31
|
+
public static void main(String[] args){
|
32
|
+
|
33
|
+
Scanner sc = null;
|
34
|
+
File code = null;
|
35
|
+
PrintWriter pw = null;
|
36
|
+
File stdin = null;
|
37
|
+
PrintWriter pw2 = null;
|
38
|
+
String str = null;
|
39
|
+
BufferedReader br = null;
|
40
|
+
Process compile = null;
|
41
|
+
Runtime r = null;
|
42
|
+
InputStream run = null;
|
43
|
+
|
44
|
+
try{
|
45
|
+
sc = new Scanner(System.in);
|
46
|
+
code = new File("Main.java");
|
47
|
+
stdin = new File("test.in");
|
48
|
+
pw = new PrintWriter(new BufferedWriter(new FileWriter(code)));
|
49
|
+
pw2 = new PrintWriter(new BufferedWriter(new FileWriter(stdin)));
|
50
|
+
while(true){
|
51
|
+
str = sc.next();
|
52
|
+
if(str.equals("<$><*><$><*><$><*><$><*><$><*><$><*><$>")){
|
53
|
+
break;
|
54
|
+
}
|
55
|
+
pw.println(str);
|
56
|
+
}
|
57
|
+
code.createNewFile();
|
58
|
+
|
59
|
+
while(sc.hasNext()){
|
60
|
+
str = sc.next();
|
61
|
+
pw2.println(str);
|
62
|
+
}
|
63
|
+
stdin.createNewFile();
|
64
|
+
|
65
|
+
r = Runtime.getRuntime();
|
66
|
+
compile = r.exec("/opt/wandbox/openjdk-head/bin/javac Main.java");
|
67
|
+
compile.waitFor();
|
68
|
+
run = r.exec("/usr/bin/time -f '%U' /opt/wandbox/openjdk-head/bin/java Main < test.in").getInputStream();
|
69
|
+
br = new BufferedReader(new InputStreamReader(run));
|
70
|
+
String line;
|
71
|
+
while ((line = br.readLine()) != null) {
|
72
|
+
System.out.println(line);
|
73
|
+
}
|
74
|
+
}catch(Exception e ){
|
75
|
+
e.printStackTrace();
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}*/
|
@@ -2,21 +2,27 @@
|
|
2
2
|
#include <fstream>
|
3
3
|
using namespace std;
|
4
4
|
|
5
|
+
char command[1024];
|
6
|
+
|
5
7
|
int main(int argc, char const *argv[])
|
6
8
|
{
|
7
9
|
ofstream ofs;
|
8
|
-
ofs.open("
|
10
|
+
ofs.open("main.rb",ios::binary);
|
9
11
|
string buf;
|
12
|
+
string splitter="<$><*><$>";
|
13
|
+
string time;
|
10
14
|
while(getline(cin,buf)){
|
11
|
-
if(buf==
|
15
|
+
if(buf==splitter)break;
|
12
16
|
ofs<<buf<<endl;
|
13
17
|
}
|
14
18
|
ofs.close();
|
15
19
|
ofs.open("test.in",ios::binary);
|
16
20
|
while(getline(cin,buf)){
|
21
|
+
if(buf==splitter)break;
|
17
22
|
ofs<<buf<<endl;
|
18
23
|
}
|
19
24
|
ofs.close();
|
20
|
-
|
25
|
+
cin>>time;
|
26
|
+
system(("timeout -s 9 " + time + " /opt/wandbox/ruby-head/bin/ruby main.rb < test.in").c_str());
|
21
27
|
return 0;
|
22
28
|
}
|
data/lib/judge_system.rb
CHANGED
@@ -30,7 +30,7 @@ module JudgeSystem
|
|
30
30
|
response = http.request(request)
|
31
31
|
JSON.parse(response.body)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
end
|
35
35
|
module_function :compile
|
36
36
|
end
|
@@ -41,19 +41,21 @@ module JudgeSystem
|
|
41
41
|
path = File.expand_path('../', __FILE__ )
|
42
42
|
sys = File.open("#{path}/compile_systems/#{lang}_system.cpp", "r").read
|
43
43
|
data = nil
|
44
|
-
|
44
|
+
spliter = "\n<$><*><$>\n"
|
45
|
+
stdin = code + spliter + input + spliter + time.to_s
|
45
46
|
begin
|
46
|
-
|
47
|
+
p data = Web.compile({ compiler: "gcc-head", code: sys, stdin: stdin })
|
47
48
|
rescue
|
48
49
|
return 'RE'
|
49
50
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
error = data["program_error"]
|
52
|
+
result = data["program_output"]
|
53
|
+
if error == "Killed\n"
|
54
|
+
return 'TLE'
|
55
|
+
elsif result == nil && error
|
56
|
+
return "RE"
|
55
57
|
else
|
56
|
-
return
|
58
|
+
return result
|
57
59
|
end
|
58
60
|
end
|
59
61
|
module_function :run
|
data/lib/judge_system/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: judge_system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshifumi Kiyono
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|