forked from ouuan/BZOJ-Local-Judge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopentest.cpp
51 lines (44 loc) · 1.36 KB
/
opentest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// opentest <problemid> <testid>
#include <iostream>
#include <direct.h>
#include <fstream>
#include <cstdlib>
#include <string>
#include <io.h>
using namespace std;
string quote(const string & s)
{
return "\"" + s + "\"";
}
int main(int argc, char* argv[])
{
if (argc != 3)
{
puts("opentest <problemid> <testid>");
return 1;
}
string problemid = argv[1];
string testid = argv[2];
string pwd = getcwd(NULL, 0);
system(quote(pwd + "\\data\\" + problemid + "\\" + testid + ".in").c_str());
string anspath = pwd + "\\data\\" + problemid + "\\" + testid + ".out";
if (_access(anspath.c_str(), 0) == -1)
{
anspath = pwd + "\\data\\" + problemid + "\\" + testid + ".ans";
if (_access(anspath.c_str(), 0) == -1)
{
cout << "Please enter answer file suffix for the test point " << testid << ": ";
string ans_suffix;
cin >> ans_suffix;
anspath = pwd + "\\data\\" + problemid + "\\" + testid + "." + ans_suffix;
if (_access(anspath.c_str(), 0) == -1)
{
cout << "Unable to find the answer file for the test point " + testid << endl;
return 1;
}
}
}
system(quote(anspath).c_str());
system(quote(pwd + "\\problems\\" + problemid + "\\" + testid + ".out").c_str());
return 0;
}