|
@@ -9,59 +9,28 @@
|
|
|
*/
|
|
|
|
|
|
#include "testlib.h"
|
|
|
-
|
|
|
-#include <iostream>
|
|
|
-#include <sstream>
|
|
|
-#include <fstream>
|
|
|
-#include <iomanip>
|
|
|
-#include <string>
|
|
|
-#include <cstdlib>
|
|
|
-#include <cstdio>
|
|
|
-#include <cstring>
|
|
|
-#include <cmath>
|
|
|
-#include <ctime>
|
|
|
-#include <climits>
|
|
|
-#include <cassert>
|
|
|
#include <vector>
|
|
|
-#include <queue>
|
|
|
-#include <stack>
|
|
|
-#include <deque>
|
|
|
-#include <set>
|
|
|
-#include <map>
|
|
|
-#include <bitset>
|
|
|
-#include <utility>
|
|
|
-#include <algorithm>
|
|
|
+#include <string>
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
-#define forn(i, n) for (int i = 0; i < int(n); i++)
|
|
|
-
|
|
|
-string token;
|
|
|
-
|
|
|
-vector<long long> readStreamCase(InStream& in, TResult pe, int testCase, bool& prereadCase)
|
|
|
-{
|
|
|
- if (!prereadCase)
|
|
|
- {
|
|
|
+vector<long long> readStreamCase(InStream &in, int testCase, bool &prereadCase) {
|
|
|
+ if (!prereadCase) {
|
|
|
string caseStr = in.readToken();
|
|
|
if (caseStr != "Case")
|
|
|
- quitf(pe, "Expected 'Case' but found '%s' [test case %d]", compress(caseStr).c_str(), testCase);
|
|
|
+ in.quitf(_pe, "Expected 'Case' but found '%s' [test case %d]", compress(caseStr).c_str(), testCase);
|
|
|
}
|
|
|
|
|
|
- string numExpStr;
|
|
|
- stringstream ss;
|
|
|
- ss << testCase;
|
|
|
- ss >> numExpStr;
|
|
|
- numExpStr += ":";
|
|
|
+ string numExpStr = to_string(testCase) + ":";
|
|
|
string numStr = in.readToken();
|
|
|
if (numExpStr != numStr)
|
|
|
- quitf(pe, "Expected '%s' but found '%s' [test case %d]", compress(numExpStr).c_str(), compress(numStr).c_str(), testCase);
|
|
|
+ in.quitf(_pe, "Expected '%s' but found '%s' [test case %d]", compress(numExpStr).c_str(),
|
|
|
+ compress(numStr).c_str(), testCase);
|
|
|
|
|
|
vector<long long> result;
|
|
|
- while (!in.seekEof())
|
|
|
- {
|
|
|
- in.readTokenTo(token);
|
|
|
- if (token == "Case")
|
|
|
- {
|
|
|
+ while (!in.seekEof()) {
|
|
|
+ string token = in.readToken();
|
|
|
+ if (token == "Case") {
|
|
|
prereadCase = true;
|
|
|
break;
|
|
|
}
|
|
@@ -72,31 +41,26 @@ vector<long long> readStreamCase(InStream& in, TResult pe, int testCase, bool& p
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-string longLongsToString(const vector<long long>& a)
|
|
|
-{
|
|
|
+string longLongsToString(const vector<long long> &a) {
|
|
|
if (a.empty())
|
|
|
return "\"\" [size=0]";
|
|
|
-
|
|
|
+
|
|
|
string elems;
|
|
|
- if (a.size() <= 5)
|
|
|
- {
|
|
|
- forn(i, a.size())
|
|
|
- elems += vtos(a[i]) + " ";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- forn(i, 3)
|
|
|
+ if (a.size() <= 5) {
|
|
|
+ for (auto elem: a)
|
|
|
+ elems += vtos(elem) + " ";
|
|
|
+ } else {
|
|
|
+ for (int i = 0; i < 3; i++)
|
|
|
elems += vtos(a[i]) + " ";
|
|
|
elems += "... ";
|
|
|
- forn(i, 2)
|
|
|
+ for (int i = 0; i < 2; i++)
|
|
|
elems += vtos(a[a.size() - 2 + i]) + " ";
|
|
|
}
|
|
|
|
|
|
- return format("\"%s\" [size=%u]", trim(elems).c_str(), (unsigned int)(a.size()));
|
|
|
+ return format("\"%s\" [size=%u]", trim(elems).c_str(), (unsigned int) (a.size()));
|
|
|
}
|
|
|
|
|
|
-int main(int argc, char* argv[])
|
|
|
-{
|
|
|
+int main(int argc, char *argv[]) {
|
|
|
setName("Many int64s checker with testcase-support");
|
|
|
registerTestlibCmd(argc, argv);
|
|
|
|
|
@@ -105,18 +69,17 @@ int main(int argc, char* argv[])
|
|
|
bool ansPrereadCase = false;
|
|
|
bool oufPrereadCase = false;
|
|
|
|
|
|
- while (!ans.seekEof())
|
|
|
- {
|
|
|
+ while (!ans.seekEof()) {
|
|
|
testCase++;
|
|
|
|
|
|
- vector<long long> ja = readStreamCase(ans, _fail, testCase, ansPrereadCase);
|
|
|
- vector<long long> pa = readStreamCase(ouf, _pe, testCase, oufPrereadCase);
|
|
|
+ vector<long long> ja = readStreamCase(ans, testCase, ansPrereadCase);
|
|
|
+ vector<long long> pa = readStreamCase(ouf, testCase, oufPrereadCase);
|
|
|
|
|
|
- if (ja != pa)
|
|
|
- {
|
|
|
+ if (ja != pa) {
|
|
|
string js = longLongsToString(ja);
|
|
|
string ps = longLongsToString(pa);
|
|
|
- quitf(_wa, "Sequences differ: jury has %s, but participant has %s [test case %d]", js.c_str(), ps.c_str(), testCase);
|
|
|
+ quitf(_wa, "Sequences differ: jury has %s, but participant has %s [test case %d]", js.c_str(), ps.c_str(),
|
|
|
+ testCase);
|
|
|
}
|
|
|
}
|
|
|
|