use v5.14;
no if $] > 5.017011, warnings => 'experimental::smartmatch';
+use File::Copy qw/copy/;
+
my ($format, $basename, $name) = @ARGV;
my $ret = fork // die $!;
if ($ret) {
- $SIG{ALRM} = sub {kill KILL => $ret};
- alarm 5;
- wait;
- exit $? >> 8
+ $SIG{ALRM} = sub {kill KILL => $ret};
+ alarm 5;
+ wait;
+ exit $? >> 8
} else {
- given ($format){
- exec 'g++', '-o', $basename, $name when 'CPP';
- }
+ given ($format){
+ exec 'gcc', qw/-DONLINE_JUDGE -std=gnu11 -Wextra -O2 -o/, $basename, $name when 'C';
+ exec 'g++', qw/-DONLINE_JUDGE -std=gnu++11 -fabi-version=6 -Wextra -O2 -o/, $basename, $name when 'CPP';
+ exec 'gmcs', '-d:ONLINE_JUDGE', $name when 'MONO';
+ exec 'javac', $name when 'JAVA';
+ exec 'fpc', qw/-dONLINE_JUDGE -O2 -n/, $name when 'PASCAL';
+ copy $name, $basename when ['PERL', 'PYTHON']
+ }
}
use strict;
use warnings;
use parent qw/Exporter/;
+no if $] > 5.017011, warnings => 'experimental::smartmatch';
use POSIX qw//;
use File::Basename qw/fileparse/;
sub command_and_args{
my ($format, $basename) = @_;
- return "./$basename" if $format eq 'CPP';
- die
+
+ given($format) {
+ "./$basename" when [qw/C CPP PASCAL/];
+ "./$basename.exe" when 'MONO';
+ "java $basename" when 'JAVA';
+ "perl $basename" when 'PERL';
+ "python $basename" when 'PYTHON';
+ default { die "Don't know how to execute format $format" }
+ }
}
sub mkrun{