This repository has been archived by the owner on May 21, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathopenmin.cpp
89 lines (72 loc) · 1.83 KB
/
openmin.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// openmin <problemid>
#include <direct.h>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <io.h>
#include <map>
using namespace std;
string quote(const string & s)
{
return "\"" + s + "\"";
}
string problemid;
map<string, string> res;
int main(int argc, char* argv[])
{
if (argc != 2)
{
puts("openmin <problemid>");
return 1;
}
problemid = argv[1];
string pwd = getcwd(NULL, 0);
string testid, result;
ifstream resin(pwd + "\\problems\\" + problemid + "\\judge.out");
getline(resin, result);
getline(resin, result);
getline(resin, result);
getline(resin, result);
getline(resin, result);
while (resin >> result)
{
resin >> testid >> result;
resin >> result;
res[testid] = result;
getline(resin, result);
getline(resin, result);
getline(resin, result);
}
intptr_t handle;
_finddata_t findData;
handle = _findfirst((pwd + "\\data\\" + problemid + "\\*.in").c_str(), &findData);
if (handle == -1)
{
puts("No data found!");
return 1;
}
unsigned int minSize = 0x7fffffff;
string minTest;
do
{
if (!(findData.attrib & _A_SUBDIR && strcmp(findData.name, ".") == 0 && strcmp(findData.name, "..") == 0))
{
string name = findData.name;
int p = name.rfind(".");
name = name.substr(0, p);
if (res[name] != "Accepted" && findData.size < minSize)
{
minSize = findData.size;
minTest = name;
}
}
} while (_findnext(handle, &findData) == 0);
if (minTest == "")
{
puts("You have already got an AC!");
return 1;
}
system(("opentest " + problemid + " " + minTest).c_str());
return 0;
}