Explorar el Código

Merge pull request #144 from MikeMirzayanov/dev-kan

Updated examples to match current standards
Mike Mirzayanov hace 1 año
padre
commit
7af31712ef

+ 1 - 1
README.md

@@ -6,7 +6,7 @@ This project contains C++ implementation of the testlib. It is already being use
 
 The library C++ code is tested for compatibility with the standard C++11 and higher on different versions of `g++`, `clang++` and Microsoft Visual C++.
 
-This code used many times on Codeforces contests.
+This code was used many times on Codeforces contests.
 
 ## Samples
 

+ 4 - 6
checkers/acmp.cpp

@@ -1,19 +1,17 @@
 #include "testlib.h"
-#include <stdio.h>
-#include <math.h>
+#include <cmath>
 
 const double EPS = 1.5E-6;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare two doubles, maximal absolute error = %.10f", EPS);
     registerTestlibCmd(argc, argv);
-    
+
     double ja = ans.readDouble();
     double pa = ouf.readDouble();
 
     if (fabs(ja - pa) > EPS + 1E-15)
         quitf(_wa, "expected %.10f, found %.10f", ja, pa);
-    
+
     quitf(_ok, "answer is %.10f", ja);
 }

+ 19 - 50
checkers/caseicmp.cpp

@@ -9,51 +9,24 @@
  */
 
 #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++)
-
-vector<long long> readStream(InStream& in, TResult pe)
-{
+vector<long long> readStream(InStream &in) {
     vector<long long> result;
 
-    for (int testCase = 1; !in.seekEof(); testCase++)
-    {
+    for (int testCase = 1; !in.seekEof(); testCase++) {
         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);
 
         result.push_back(in.readLong());
     }
@@ -61,33 +34,29 @@ vector<long long> readStream(InStream& in, TResult pe)
     return result;
 }
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     setName("Single int64 checker with testcase-support");
     registerTestlibCmd(argc, argv);
 
-    vector<long long> ja = readStream(ans, _fail);
-    vector<long long> pa = readStream(ouf, _pe);
+    vector<long long> ja = readStream(ans);
+    vector<long long> pa = readStream(ouf);
 
-    forn(i, min(ja.size(), pa.size()))
+    for (unsigned int i = 0; i < min(ja.size(), pa.size()); i++)
         if (ja[i] != pa[i])
             quitf(_wa, "Expected %s found %s [test case %d]", vtos(ja[i]).c_str(), vtos(pa[i]).c_str(), i + 1);
 
     if (ja.size() != pa.size())
-        quitf(_pe, "Expected %u test case(s) but found %u", (unsigned int)(ja.size()), (unsigned int)(pa.size()));
+        quitf(_pe, "Expected %u test case(s) but found %u", (unsigned int) (ja.size()), (unsigned int) (pa.size()));
 
-    string message = format("%u case(s):", (unsigned int)(ja.size()));
-    if (ja.size() <= 5)
-    {
-        forn(i, ja.size())
-            message += " " + vtos(ja[i]);
-    }
-    else
-    {
-        forn(i, 3)
+    string message = format("%u case(s):", (unsigned int) (ja.size()));
+    if (ja.size() <= 5) {
+        for (auto elem: ja)
+            message += " " + vtos(elem);
+    } else {
+        for (int i = 0; i < 3; i++)
             message += " " + vtos(ja[i]);
         message += " ...";
-        forn(i, 2)
+        for (int i = 0; i < 2; i++)
             message += " " + vtos(ja[ja.size() - 2 + i]);
     }
 

+ 26 - 63
checkers/casencmp.cpp

@@ -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);
         }
     }
 

+ 23 - 56
checkers/casewcmp.cpp

@@ -6,62 +6,32 @@
  * ...
  * Case n: <token> <token> ... <token>
  *
+ * Tokens in each case should not contain "Case"
  */
 
 #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<string> readStreamCase(InStream& in, TResult pe, int testCase, bool& prereadCase)
-{
-    if (!prereadCase)
-    {
+vector<string> 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<string> result;
-    while (!in.seekEof())
-    {
-        in.readTokenTo(token);
-        if (token == "Case")
-        {
+    while (!in.seekEof()) {
+        string token = in.readToken();
+        if (token == "Case") {
             prereadCase = true;
             break;
         }
@@ -72,20 +42,18 @@ vector<string> readStreamCase(InStream& in, TResult pe, int testCase, bool& prer
     return result;
 }
 
-string stringsToString(const vector<string>& a)
-{
+string stringsToString(const vector<string> &a) {
     if (a.empty())
         return "\"\" [size=0]";
-    
+
     string elems;
-    forn(i, a.size())
-        elems += a[i] + " ";
+    for (const auto& token: a)
+        elems += token + " ";
 
-    return format("\"%s\" [size=%u]", compress(trim(elems)).c_str(), (unsigned int)(a.size()));
+    return format("\"%s\" [size=%u]", compress(trim(elems)).c_str(), (unsigned int) (a.size()));
 }
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     setName("Tokens checker with testcase-support");
     registerTestlibCmd(argc, argv);
 
@@ -94,18 +62,17 @@ int main(int argc, char* argv[])
     bool ansPrereadCase = false;
     bool oufPrereadCase = false;
 
-    while (!ans.seekEof())
-    {
+    while (!ans.seekEof()) {
         testCase++;
 
-        vector<string> ja = readStreamCase(ans, _fail, testCase, ansPrereadCase);
-        vector<string> pa = readStreamCase(ouf, _pe, testCase, oufPrereadCase);
+        vector<string> ja = readStreamCase(ans, testCase, ansPrereadCase);
+        vector<string> pa = readStreamCase(ouf, testCase, oufPrereadCase);
 
-        if (ja != pa)
-        {
+        if (ja != pa) {
             string js = stringsToString(ja);
             string ps = stringsToString(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);
         }
     }
 

+ 4 - 7
checkers/dcmp.cpp

@@ -1,19 +1,16 @@
 #include "testlib.h"
-#include <stdio.h>
-#include <math.h>
 
 const double EPS = 1E-6;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare two doubles, maximal absolute or relative error = %.10f", EPS);
     registerTestlibCmd(argc, argv);
-    
+
     double ja = ans.readDouble();
     double pa = ouf.readDouble();
-    
+
     if (!doubleCompare(ja, pa, EPS))
         quitf(_wa, "expected %.10f, found %.10f", ja, pa);
-    
+
     quitf(_ok, "answer is %.10f", ja);
 }

+ 8 - 11
checkers/fcmp.cpp

@@ -1,24 +1,20 @@
 #include "testlib.h"
 #include <string>
-#include <vector>
-#include <sstream>
 
 using namespace std;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare files as sequence of lines");
     registerTestlibCmd(argc, argv);
 
     std::string strAnswer;
 
     int n = 0;
-    while (!ans.eof()) 
-    {
+    while (!ans.eof()) {
         std::string j = ans.readString();
 
-        if (j == "" && ans.eof())
-          break;
+        if (j.empty() && ans.eof())
+            break;
 
         strAnswer = j;
         std::string p = ouf.readString();
@@ -26,11 +22,12 @@ int main(int argc, char * argv[])
         n++;
 
         if (j != p)
-            quitf(_wa, "%d%s lines differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(), compress(j).c_str(), compress(p).c_str());
+            quitf(_wa, "%d%s lines differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(),
+                  compress(j).c_str(), compress(p).c_str());
     }
-    
+
     if (n == 1)
         quitf(_ok, "single line: '%s'", compress(strAnswer).c_str());
-    
+
     quitf(_ok, "%d lines", n);
 }

+ 5 - 8
checkers/hcmp.cpp

@@ -1,21 +1,18 @@
 #include "testlib.h"
-
 #include <string>
 
 using namespace std;
 
 pattern pnum("0|-?[1-9][0-9]*");
 
-bool isNumeric(const string& p)
-{
+bool isNumeric(const string &p) {
     return pnum.matches(p);
 }
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare two signed huge integers");
     registerTestlibCmd(argc, argv);
-    
+
     string ja = ans.readWord();
     string pa = ouf.readWord();
 
@@ -24,12 +21,12 @@ int main(int argc, char * argv[])
 
     if (!ans.seekEof())
         quitf(_fail, "expected exactly one token in the answer file");
-    
+
     if (!isNumeric(pa))
         quitf(_pe, "%s is not a valid integer", compress(pa).c_str());
 
     if (ja != pa)
         quitf(_wa, "expected '%s', found '%s'", compress(ja).c_str(), compress(pa).c_str());
-    
+
     quitf(_ok, "answer is '%s'", compress(ja).c_str());
 }

+ 4 - 6
checkers/icmp.cpp

@@ -1,16 +1,14 @@
 #include "testlib.h"
-#include <stdio.h>
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare two signed int%d's", 8 * int(sizeof(int)));
     registerTestlibCmd(argc, argv);
-    
+
     int ja = ans.readInt();
     int pa = ouf.readInt();
-    
+
     if (ja != pa)
         quitf(_wa, "expected %d, found %d", ja, pa);
-    
+
     quitf(_ok, "answer is %d", ja);
 }

+ 13 - 15
checkers/lcmp.cpp

@@ -5,11 +5,10 @@
 
 using namespace std;
 
-bool compareWords(string a, string b)
-{
+bool compareWords(const string& a, const string& b) {
     vector<string> va, vb;
     stringstream sa;
-    
+
     sa << a;
     string cur;
     while (sa >> cur)
@@ -23,32 +22,31 @@ bool compareWords(string a, string b)
     return (va == vb);
 }
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare files as sequence of tokens in lines");
     registerTestlibCmd(argc, argv);
 
-    std::string strAnswer;
+    string strAnswer;
 
     int n = 0;
-    while (!ans.eof()) 
-    {
+    while (!ans.eof()) {
         std::string j = ans.readString();
 
-        if (j == "" && ans.eof())
-          break;
-        
-        std::string p = ouf.readString();
+        if (j.empty() && ans.eof())
+            break;
+
+        string p = ouf.readString();
         strAnswer = p;
 
         n++;
 
         if (!compareWords(j, p))
-            quitf(_wa, "%d%s lines differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(), compress(j).c_str(), compress(p).c_str());
+            quitf(_wa, "%d%s lines differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(),
+                  compress(j).c_str(), compress(p).c_str());
     }
-    
+
     if (n == 1)
         quitf(_ok, "single line: '%s'", compress(strAnswer).c_str());
-    
+
     quitf(_ok, "%d lines", n);
 }

+ 18 - 22
checkers/ncmp.cpp

@@ -1,10 +1,8 @@
 #include "testlib.h"
-#include <sstream>
 
 using namespace std;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare ordered sequences of signed int%d numbers", 8 * int(sizeof(long long)));
 
     registerTestlibCmd(argc, argv);
@@ -12,44 +10,42 @@ int main(int argc, char * argv[])
     int n = 0;
     string firstElems;
 
-    while (!ans.seekEof() && !ouf.seekEof())
-    {
+    while (!ans.seekEof() && !ouf.seekEof()) {
         n++;
         long long j = ans.readLong();
         long long p = ouf.readLong();
         if (j != p)
-            quitf(_wa, "%d%s numbers differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(), vtos(j).c_str(), vtos(p).c_str());
-        else
-            if (n <= 5)
-            {
-                if (firstElems.length() > 0)
-                    firstElems += " ";
-                firstElems += vtos(j);
-            }
+            quitf(_wa, "%d%s numbers differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(),
+                  vtos(j).c_str(), vtos(p).c_str());
+        else if (n <= 5) {
+            if (firstElems.length() > 0)
+                firstElems += " ";
+            firstElems += vtos(j);
+        }
     }
 
     int extraInAnsCount = 0;
 
-    while (!ans.seekEof())
-    {
+    while (!ans.seekEof()) {
         ans.readLong();
         extraInAnsCount++;
     }
-    
+
     int extraInOufCount = 0;
 
-    while (!ouf.seekEof())
-    {
+    while (!ouf.seekEof()) {
         ouf.readLong();
         extraInOufCount++;
     }
 
     if (extraInAnsCount > 0)
-        quitf(_wa, "Answer contains longer sequence [length = %d], but output contains %d elements", n + extraInAnsCount, n);
-    
+        quitf(_wa, "Answer contains longer sequence [length = %d], but output contains %d elements",
+              n + extraInAnsCount, n);
+
     if (extraInOufCount > 0)
-        quitf(_wa, "Output contains longer sequence [length = %d], but answer contains %d elements", n + extraInOufCount, n);
-    
+        quitf(_wa, "Output contains longer sequence [length = %d], but answer contains %d elements",
+              n + extraInOufCount, n);
+
     if (n <= 5)
         quitf(_ok, "%d number(s): \"%s\"", n, compress(firstElems).c_str());
     else

+ 15 - 17
checkers/nyesno.cpp

@@ -6,22 +6,20 @@ using namespace std;
 const string YES = "YES";
 const string NO = "NO";
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("%s", ("multiple " + YES + "/" + NO + " (case insensetive)").c_str());
     registerTestlibCmd(argc, argv);
 
     int index = 0, yesCount = 0, noCount = 0;
-    std::string pa;
-    while (!ans.seekEof() && !ouf.seekEof())
-    {
+    string pa;
+    while (!ans.seekEof() && !ouf.seekEof()) {
         index++;
-        std::string ja = upperCase(ans.readToken());
+        string ja = upperCase(ans.readToken());
         pa = upperCase(ouf.readToken());
 
         if (ja != YES && ja != NO)
             quitf(_fail, "%s or %s expected in answer, but %s found [%d%s token]",
-                YES.c_str(), NO.c_str(), compress(ja).c_str(), index, englishEnding(index).c_str());
+                  YES.c_str(), NO.c_str(), compress(ja).c_str(), index, englishEnding(index).c_str());
 
         if (pa == YES)
             yesCount++;
@@ -29,32 +27,32 @@ int main(int argc, char * argv[])
             noCount++;
         else
             quitf(_pe, "%s or %s expected, but %s found [%d%s token]",
-                YES.c_str(), NO.c_str(), compress(pa).c_str(), index, englishEnding(index).c_str());
+                  YES.c_str(), NO.c_str(), compress(pa).c_str(), index, englishEnding(index).c_str());
 
         if (ja != pa)
             quitf(_wa, "expected %s, found %s [%d%s token]",
-                compress(ja).c_str(), compress(pa).c_str(), index, englishEnding(index).c_str());
+                  compress(ja).c_str(), compress(pa).c_str(), index, englishEnding(index).c_str());
     }
 
     int extraInAnsCount = 0;
-    while (!ans.seekEof())
-    {
+    while (!ans.seekEof()) {
         ans.readToken();
         extraInAnsCount++;
     }
-    
+
     int extraInOufCount = 0;
-    while (!ouf.seekEof())
-    {
+    while (!ouf.seekEof()) {
         ouf.readToken();
         extraInOufCount++;
     }
 
     if (extraInAnsCount > 0)
-        quitf(_wa, "Answer contains longer sequence [length = %d], but output contains %d elements", index + extraInAnsCount, index);
-    
+        quitf(_wa, "Answer contains longer sequence [length = %d], but output contains %d elements",
+              index + extraInAnsCount, index);
+
     if (extraInOufCount > 0)
-        quitf(_wa, "Output contains longer sequence [length = %d], but answer contains %d elements", index + extraInOufCount, index);
+        quitf(_wa, "Output contains longer sequence [length = %d], but answer contains %d elements",
+              index + extraInOufCount, index);
 
     if (index == 0)
         quitf(_ok, "Empty output");

+ 1 - 2
checkers/pointscmp.cpp

@@ -2,8 +2,7 @@
 
 using namespace std;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("example of scored checker");
     registerTestlibCmd(argc, argv);
 

+ 2 - 3
checkers/pointsinfo.cpp

@@ -2,14 +2,13 @@
 
 using namespace std;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("example of checker with points_info");
     registerTestlibCmd(argc, argv);
 
     double pa = ouf.readDouble();
     double ja = ans.readDouble();
-                           
+
     string points_info = "pa=" + to_string(pa) + ",ja=" + to_string(ja);
     quitpi(points_info, "d=" + to_string(abs(ja - pa)));
 }

+ 4 - 6
checkers/rcmp.cpp

@@ -1,19 +1,17 @@
 #include "testlib.h"
-#include <stdio.h>
-#include <math.h>
+#include <cmath>
 
 const double EPS = 1.5E-6;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare two doubles, maximal absolute error = %.10f", EPS);
     registerTestlibCmd(argc, argv);
-    
+
     double ja = ans.readDouble();
     double pa = ouf.readDouble();
 
     if (fabs(ja - pa) > EPS + 1E-15)
         quitf(_wa, "expected %.10f, found %.10f", ja, pa);
-    
+
     quitf(_ok, "answer is %.10f", ja);
 }

+ 5 - 9
checkers/rcmp4.cpp

@@ -1,32 +1,28 @@
 #include "testlib.h"
-#include <cmath>
 
 using namespace std;
 
 const double EPS = 1E-4;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare two sequences of doubles, max absolute or relative error = %.5f", EPS);
     registerTestlibCmd(argc, argv);
 
     int n = 0;
     double j = 0, p = 0;
 
-    while (!ans.seekEof()) 
-    {
+    while (!ans.seekEof()) {
         n++;
         j = ans.readDouble();
         p = ouf.readDouble();
-        if (!doubleCompare(j, p, EPS))
-        {
+        if (!doubleCompare(j, p, EPS)) {
             quitf(_wa, "%d%s numbers differ - expected: '%.5f', found: '%.5f', error = '%.5f'",
-                n, englishEnding(n).c_str(), j, p, doubleDelta(j, p));
+                  n, englishEnding(n).c_str(), j, p, doubleDelta(j, p));
         }
     }
 
     if (n == 1)
         quitf(_ok, "found '%.5f', expected '%.5f', error '%.5f'", p, j, doubleDelta(j, p));
-    
+
     quitf(_ok, "%d numbers", n);
 }

+ 4 - 8
checkers/rcmp6.cpp

@@ -1,27 +1,23 @@
 #include "testlib.h"
-#include <cmath>
 
 using namespace std;
 
 const double EPS = 1E-6;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare two sequences of doubles, max absolute or relative  error = %.7f", EPS);
     registerTestlibCmd(argc, argv);
 
     int n = 0;
     double j = 0, p = 0;
 
-    while (!ans.seekEof()) 
-    {
+    while (!ans.seekEof()) {
         n++;
         j = ans.readDouble();
         p = ouf.readDouble();
-        if (!doubleCompare(j, p, EPS))
-        {
+        if (!doubleCompare(j, p, EPS)) {
             quitf(_wa, "%d%s numbers differ - expected: '%.7f', found: '%.7f', error = '%.7f'",
-                n, englishEnding(n).c_str(), j, p, doubleDelta(j, p));
+                  n, englishEnding(n).c_str(), j, p, doubleDelta(j, p));
         }
     }
 

+ 4 - 8
checkers/rcmp9.cpp

@@ -1,27 +1,23 @@
 #include "testlib.h"
-#include <cmath>
 
 using namespace std;
 
 const double EPS = 1E-9;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare two sequences of doubles, max absolute or relative error = %.10f", EPS);
     registerTestlibCmd(argc, argv);
 
     int n = 0;
     double j = 0, p = 0;
 
-    while (!ans.seekEof()) 
-    {
+    while (!ans.seekEof()) {
         n++;
         j = ans.readDouble();
         p = ouf.readDouble();
-        if (!doubleCompare(j, p, EPS))
-        {
+        if (!doubleCompare(j, p, EPS)) {
             quitf(_wa, "%d%s numbers differ - expected: '%.10f', found: '%.10f', error = '%.10f'",
-                n, englishEnding(n).c_str(), j, p, doubleDelta(j, p));
+                  n, englishEnding(n).c_str(), j, p, doubleDelta(j, p));
         }
     }
 

+ 2 - 4
checkers/rncmp.cpp

@@ -5,14 +5,12 @@ using namespace std;
 
 const double EPS = 1.5E-5;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare two sequences of doubles, maximal absolute error = %.10f", EPS);
     registerTestlibCmd(argc, argv);
 
     int n = 0;
-    while (!ans.seekEof()) 
-    {
+    while (!ans.seekEof()) {
         n++;
         double j = ans.readDouble();
         double p = ouf.readDouble();

+ 8 - 9
checkers/uncmp.cpp

@@ -3,8 +3,7 @@
 
 using namespace std;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare unordered sequences of signed int%u numbers", int(8 * sizeof(long long)));
 
     registerTestlibCmd(argc, argv);
@@ -18,16 +17,17 @@ int main(int argc, char * argv[])
         pa.push_back(ouf.readLong());
 
     if (ja.size() != pa.size())
-        quitf(_wa, "Expected %u elements, but %u found", (unsigned int)(ja.size()), (unsigned int)(pa.size()));
+        quitf(_wa, "Expected %u elements, but %u found", (unsigned int) (ja.size()), (unsigned int) (pa.size()));
 
     sort(ja.begin(), ja.end());
     sort(pa.begin(), pa.end());
 
     if (ja != pa)
-        quitf(_wa, "Expected sequence and output are different (as unordered sequences) [size=%u]", (unsigned int)(ja.size()));
+        quitf(_wa, "Expected sequence and output are different (as unordered sequences) [size=%u]",
+              (unsigned int) (ja.size()));
 
     string message;
-    
+
     if (ja.size() != 1)
         if (ja.empty())
             message = "empty sequence";
@@ -35,18 +35,17 @@ int main(int argc, char * argv[])
             message = vtos(ja.size()) + " numbers (in increasing order):";
     else
         message = vtos(ja.size()) + " number:";
-    
+
     if (ja.size() <= 5)
         for (int i = 0; i < min(int(ja.size()), 5); i++)
             message += " " + vtos(ja[i]);
-    else
-    {
+    else {
         for (int i = 0; i < 2; i++)
             message += " " + vtos(ja[i]);
         message += " ...";
         for (int i = 0; i < 2; i++)
             message += " " + vtos(ja[ja.size() - 2 + i]);
     }
-        
+
     quitf(_ok, "%s", message.c_str());
 }

+ 7 - 11
checkers/wcmp.cpp

@@ -2,34 +2,30 @@
 
 using namespace std;
 
-int main(int argc, char * argv[])
-{
+int main(int argc, char *argv[]) {
     setName("compare sequences of tokens");
     registerTestlibCmd(argc, argv);
 
     int n = 0;
     string j, p;
 
-    while (!ans.seekEof() && !ouf.seekEof()) 
-    {
+    while (!ans.seekEof() && !ouf.seekEof()) {
         n++;
 
         ans.readWordTo(j);
         ouf.readWordTo(p);
-        
+
         if (j != p)
-            quitf(_wa, "%d%s words differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(), compress(j).c_str(), compress(p).c_str());
+            quitf(_wa, "%d%s words differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(),
+                  compress(j).c_str(), compress(p).c_str());
     }
 
-    if (ans.seekEof() && ouf.seekEof())
-    {
+    if (ans.seekEof() && ouf.seekEof()) {
         if (n == 1)
             quitf(_ok, "\"%s\"", compress(j).c_str());
         else
             quitf(_ok, "%d tokens", n);
-    }
-    else
-    {
+    } else {
         if (ans.seekEof())
             quitf(_wa, "Participant output contains extra tokens");
         else

+ 2 - 3
checkers/yesno.cpp

@@ -6,9 +6,8 @@ using namespace std;
 const string YES = "YES";
 const string NO = "NO";
 
-int main(int argc, char * argv[])
-{
-    setName("%s", (YES + " or " + NO + " (case insensetive)").c_str());
+int main(int argc, char *argv[]) {
+    setName("%s", (YES + " or " + NO + " (case insensitive)").c_str());
     registerTestlibCmd(argc, argv);
 
     std::string ja = upperCase(ans.readWord());

+ 2 - 5
generators/bgen.cpp

@@ -1,6 +1,6 @@
 /*
  * Outputs random 100-digits binary string mostly containing 0's. 
- * In average it contrains only 10% of 1's.
+ * In average, it contains only 10% of 1's.
  *
  * To generate different values, call "bgen.exe" with different parameters.
  * 
@@ -8,13 +8,10 @@
  */
 
 #include "testlib.h"
-#include <iostream>
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerGen(argc, argv, 1);
     println(rnd.next("[0000000001]{100}"));
-    return 0;
 }

+ 8 - 40
generators/gen-bipartite-graph.cpp

@@ -1,33 +1,11 @@
 #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>
-
-#define forn(i, n) for (int i = 0; i < int(n); i++)
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerGen(argc, argv, 1);
 
     int n = opt<int>(1);
@@ -36,31 +14,21 @@ int main(int argc, char* argv[])
 
     int t = rnd.next(-2, 2);
 
-    set<pair<int,int> > edges;
+    set<pair<int, int>> edges;
 
-    while (edges.size() < k)
-    {
+    while (edges.size() < k) {
         int a = rnd.wnext(n, t);
         int b = rnd.wnext(m, t);
         edges.insert(make_pair(a, b));
     }
 
-    vector<pair<int,int> > e(edges.begin(), edges.end());
+    vector<pair<int, int>> e(edges.begin(), edges.end());
     shuffle(e.begin(), e.end());
 
-    vector<int> pa(n);
-    for (int i = 0; i < n; i++)
-        pa[i] = i + 1;
-    shuffle(pa.begin(), pa.end());
-
-    vector<int> pb(m);
-    for (int i = 0; i < m; i++)
-        pb[i] = i + 1;
-    shuffle(pb.begin(), pb.end());
+    vector<int> pa = rnd.perm(n, 1);
+    vector<int> pb = rnd.perm(m, 1);
 
     println(n, m, e.size());
-    forn(i, e.size())
-        println(pa[e[i].first], pb[e[i].second]);
-
-    return 0;
+    for (auto edge: e)
+        println(pa[edge.first], pb[edge.second]);
 }

+ 10 - 40
generators/gen-rooted-tree-graph.cpp

@@ -1,60 +1,30 @@
 #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>
-
-#define forn(i, n) for (int i = 0; i < int(n); i++)
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerGen(argc, argv, 1);
 
     int n = opt<int>(1);
     int t = opt<int>(2);
 
     vector<int> p(n);
-    forn(i, n)
-        if (i > 0)
-            p[i] = rnd.wnext(i, t);
+    // p[i] is the parent of i-th vertex in 0-numeration without shuffling
+    for (int i = 1; i < n; i++)
+        p[i] = rnd.wnext(i, t);
 
-    printf("%d\n", n);
     vector<int> perm(n);
-    forn(i, n)
+    for (int i = 0; i < n; i++)
         perm[i] = i;
     shuffle(perm.begin() + 1, perm.end());
 
-    vector<int> pp(n);
+    vector<int> pp(n - 1);
+    // pp[i] is the parent of (i+2)-nd vertex in 1-numeration after shuffling
     for (int i = 1; i < n; i++)
-        pp[perm[i]] = perm[p[i]];
+        pp[perm[i] - 1] = perm[p[i]] + 1;
 
-    for (int i = 1; i < n; i++)
-    {
-        printf("%d", pp[i] + 1);
-        if (i + 1 < n)
-            printf(" ");
-    }
-    printf("\n");
-
-    return 0;
+    println(n);
+    println(pp);
 }

+ 8 - 37
generators/gen-tree-graph.cpp

@@ -1,50 +1,22 @@
 #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>
-
-#define forn(i, n) for (int i = 0; i < int(n); i++)
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerGen(argc, argv, 1);
 
     int n = opt<int>(1);
     int t = opt<int>(2);
 
     vector<int> p(n);
-    forn(i, n)
-        if (i > 0)
-            p[i] = rnd.wnext(i, t);
+    for (int i = 1; i < n; i++)
+        p[i] = rnd.wnext(i, t);
 
-    printf("%d\n", n);
-    vector<int> perm(n);
-    forn(i, n)
-        perm[i] = i;
-    shuffle(perm.begin() + 1, perm.end());
-    vector<pair<int,int> > edges;
+    vector<int> perm = rnd.perm(n);
 
+    vector<pair<int, int>> edges;
     for (int i = 1; i < n; i++)
         if (rnd.next(2))
             edges.push_back(make_pair(perm[i], perm[p[i]]));
@@ -53,8 +25,7 @@ int main(int argc, char* argv[])
 
     shuffle(edges.begin(), edges.end());
 
-    for (int i = 0; i + 1 < n; i++)
-        printf("%d %d\n", edges[i].first + 1, edges[i].second + 1);
-
-    return 0;
+    println(n);
+    for (auto edge: edges)
+        println(edge.first + 1, edge.second + 1);
 }

+ 3 - 2
generators/gs.cpp

@@ -10,11 +10,12 @@
  */
 
 #include "testlib.h"
-#include <iostream>
+
+#include <string>
 
 using namespace std;
 
-int main(int argc, char* argv[]) {
+int main(int argc, char *argv[]) {
     registerGen(argc, argv, 1);
     string t;
     int n = opt<int>(1);

+ 2 - 6
generators/igen.cpp

@@ -7,15 +7,11 @@
  */
 
 #include "testlib.h"
-#include <iostream>
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerGen(argc, argv, 1);
 
-    cout << rnd.next(1, 1000000) << endl;
-
-    return 0;
+    println(rnd.next(1, 1000000));
 }

+ 2 - 6
generators/iwgen.cpp

@@ -24,15 +24,11 @@
  */
 
 #include "testlib.h"
-#include <iostream>
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerGen(argc, argv, 1);
 
-    cout << rnd.wnext(1, 1000000, opt<int>(1)) << endl;
-
-    return 0;
+    println(rnd.wnext(1, 1000000, opt<int>(1)));
 }

+ 9 - 13
generators/multigen.cpp

@@ -3,32 +3,28 @@
  * as test indices. 
  *
  * For example, this generator writes 10 files (tests) from 1 to 10.
- * This type of generators supported by Polygon too, but I believe 
- * that stdout-generators are more preferred.
+ * This type of generators is supported by Polygon too, but
+ * stdout-generators are more preferred.
  *
- * The generator for A+B problem, generates 10 tests where each 
+ * The generator is for A+B problem, generates 10 tests where each 
  * number is between 1 and 100, and tests grow with indices.
  */
 
 #include "testlib.h"
-#include <iostream>
 
 using namespace std;
 
-void writeTest(int test)
-{
+void writeTest(int test) {
     startTest(test);
-    
-    cout << rnd.next(1, test * test) 
-        << " " << rnd.next(1, test * test) << endl;
+
+    int a = rnd.next(1, test * test);
+    int b = rnd.next(1, test * test);
+    println(a, b);
 }
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerGen(argc, argv, 1);
 
     for (int i = 1; i <= 10; i++)
         writeTest(i);
-    
-    return 0;
 }

+ 2 - 6
generators/sgen.cpp

@@ -10,15 +10,11 @@
  */
 
 #include "testlib.h"
-#include <iostream>
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerGen(argc, argv, 1);
 
-    cout << rnd.next("[a-zA-Z0-9]{1,1000}") << endl;
-
-    return 0;
+    println(rnd.next("[a-zA-Z0-9]{1,1000}"));
 }

+ 2 - 6
generators/swgen.cpp

@@ -13,16 +13,12 @@
  */
 
 #include "testlib.h"
-#include <iostream>
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerGen(argc, argv, 1);
 
     int length = rnd.wnext(1, 1000, opt<int>(1));
-    cout << rnd.next("[a-zA-Z0-9]{1,%d}", length) << endl;
-
-    return 0;
+    println(rnd.next("[a-zA-Z0-9]{1,%d}", length));
 }

+ 3 - 5
interactors/interactor-a-plus-b.cpp

@@ -3,15 +3,13 @@
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     setName("Interactor A+B");
     registerInteraction(argc, argv);
-    
+
     // reads number of queries from test (input) file
     int n = inf.readInt();
-    for (int i = 0; i < n; i++)
-    {
+    for (int i = 0; i < n; i++) {
         // reads query from test (input) file
         int a = inf.readInt();
         int b = inf.readInt();

+ 0 - 2
tests/test-001_run-sval/src/sval.cpp

@@ -15,6 +15,4 @@ int main(int argc, char* argv[])
     inf.readToken("[a-z]{1,100}", "s");
     inf.readEoln();
     inf.readEof();
-
-    return 0;
 }

+ 5 - 29
validators/bipartite-graph-validator.cpp

@@ -1,33 +1,10 @@
 #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>
-
-#define forn(i, n) for (int i = 0; i < int(n); i++)
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerValidation(argc, argv);
 
     int n = inf.readInt(1, 400, "n");
@@ -37,19 +14,18 @@ int main(int argc, char* argv[])
     int k = inf.readInt(0, n * m, "k");
     inf.readEoln();
 
-    set<pair<int,int> > edges;
+    set<pair<int, int>> edges;
 
-    forn(i, k)
-    {
+    for (int i = 0; i < k; i++) {
         int a = inf.readInt(1, n, "a_i");
         inf.readSpace();
         int b = inf.readInt(1, m, "b_i");
         inf.readEoln();
 
-        ensuref(edges.count(make_pair(a, b)) == 0, "Graph can't contain multiple edges between a pair of vertices");
+        ensuref(edges.count(make_pair(a, b)) == 0,
+                "Graph can't contain multiple edges between a pair of vertices");
         edges.insert(make_pair(a, b));
     }
 
     inf.readEof();
-    return 0;
 }

+ 2 - 2
validators/case-nval.cpp

@@ -9,7 +9,7 @@
 
 using namespace std;
 
-int main(int argc, char* argv[]) {
+int main(int argc, char *argv[]) {
     registerValidation(argc, argv);
 
     int testCaseCount = inf.readInt(1, 10, "t");
@@ -22,6 +22,6 @@ int main(int argc, char* argv[]) {
         inf.readInts(n, -1000, 1000, "a");
         inf.readEoln();
     }
-    
+
     inf.readEof();
 }

+ 1 - 4
validators/ival.cpp

@@ -7,13 +7,10 @@
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerValidation(argc, argv);
 
     inf.readInt(1, 100, "n");
     inf.readEoln();
     inf.readEof();
-
-    return 0;
 }

+ 3 - 11
validators/nval.cpp

@@ -8,22 +8,14 @@
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerValidation(argc, argv);
-    
+
     int n = inf.readInt(1, 100000, "n");
     inf.readEoln();
 
-    for (int i = 0; i < n; i++)
-    {
-        inf.readLong(-1000000000000000LL, 1000000000000000LL, format("a[%d]", i + 1));
-
-        if (i + 1 < n)
-            inf.readSpace();
-    }
+    inf.readLongs(n, -1000000000LL * 1000000LL, 1000000000LL * 1000000LL, "a");
     inf.readEoln();
 
     inf.readEof();
-    return 0;
 }

+ 2 - 5
validators/sval.cpp

@@ -8,13 +8,10 @@
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerValidation(argc, argv);
-    
+
     inf.readToken("[a-z]{1,100}", "s");
     inf.readEoln();
     inf.readEof();
-
-    return 0;
 }

+ 5 - 29
validators/undirected-graph-validator.cpp

@@ -1,33 +1,10 @@
 #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>
-
-#define forn(i, n) for (int i = 0; i < int(n); i++)
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerValidation(argc, argv);
 
     int n = inf.readInt(1, 1000, "n");
@@ -35,22 +12,21 @@ int main(int argc, char* argv[])
     int m = inf.readInt(0, 100000, "m");
     inf.readEoln();
 
-    set<pair<int,int> > edges;
+    set<pair<int, int>> edges;
 
-    forn(i, m)
-    {
+    for (int i = 0; i < m; i++) {
         int a = inf.readInt(1, n, "a_i");
         inf.readSpace();
         int b = inf.readInt(1, n, "b_i");
         inf.readEoln();
 
         ensuref(a != b, "Graph can't contain loops");
-        ensuref(edges.count(make_pair(a, b)) == 0, "Graph can't contain multiple edges between a pair of vertices");
+        ensuref(edges.count(make_pair(a, b)) == 0,
+                "Graph can't contain multiple edges between a pair of vertices");
 
         edges.insert(make_pair(a, b));
         edges.insert(make_pair(b, a));
     }
 
     inf.readEof();
-    return 0;
 }

+ 7 - 34
validators/undirected-tree-validator.cpp

@@ -1,44 +1,20 @@
 #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>
-
-#define forn(i, n) for (int i = 0; i < int(n); i++)
 
 using namespace std;
 
-int leader(vector<int>& dsu, int idx)
-{
+int leader(vector<int> &dsu, int idx) {
     return dsu[idx] == idx ? dsu[idx] : (dsu[idx] = leader(dsu, dsu[idx]));
 }
 
-bool merge(vector<int>& dsu, int a, int b)
-{
+bool merge(vector<int> &dsu, int a, int b) {
     a = leader(dsu, a);
     b = leader(dsu, b);
     if (a == b)
         return false;
-    else
-    {
+    else {
         if (rnd.next(2) == 0)
             dsu[a] = b;
         else
@@ -47,21 +23,19 @@ bool merge(vector<int>& dsu, int a, int b)
     }
 }
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerValidation(argc, argv);
 
     int n = inf.readInt(2, 100000, "n");
     inf.readEoln();
 
     vector<int> dsu(n);
-    forn(i, n)
+    for (int i = 0; i < n; i++)
         dsu[i] = i;
 
-    set<pair<int,int> > edges;
+    set<pair<int, int>> edges;
 
-    forn(i, n - 1)
-    {
+    for (int i = 0; i < n - 1; i++) {
         int x = inf.readInt(1, n, "x_i");
         inf.readSpace();
         int y = inf.readInt(1, n, "y_i");
@@ -77,5 +51,4 @@ int main(int argc, char* argv[])
     }
 
     inf.readEof();
-    return 0;
 }

+ 5 - 11
validators/validate-using-testset-and-group.cpp

@@ -1,33 +1,27 @@
 /**
- * Validates that input depenging on testset and group.
+ * Validates input depending on testset and group.
  */
 
 #include "testlib.h"
-#include <iostream>
 
 using namespace std;
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char *argv[]) {
     registerValidation(argc, argv);
 
     int n, m;
 
-    if (validator.testset() == "pretests")
-    {
+    if (validator.testset() == "pretests") {
         n = inf.readInt(1, 10, "n");
         inf.readSpace();
         m = inf.readInt(1, 10, "m");
-    }
-    else
-    {
+    } else {
         n = inf.readInt(1, 100, "n");
         inf.readSpace();
         m = inf.readInt(1, 100, "m");
     }
 
-    if (validator.group() == "even-n-and-m")
-    {
+    if (validator.group() == "even-n-and-m") {
         ensure(n % 2 == 0);
         ensure(m % 2 == 0);
     }