int main(int argc, char * argv[]) { registerTestlibCmd(argc, argv); int n = inf.readInt(); while (!ouf.seekEof()) { int k = ouf.readInt(1, n); for (int i = 0; i < n; ++i) a[i] = 0; for (int i = 0; i < k; ++i) { int j = ouf.readInt(1, n) - 1; a[j]++; } int x = 0; for (int i = 0; i < n; ++i) { if (a[i] > 1) quit(_wa, "Same student appears more than once"); x = x * 2 + a[i]; } c[x]++; } for (int i = 1; i < (1 << n); ++i) { if (c[i] == 0) quitf(_wa, "Subset #%d not found", i); if (c[i] > 1) quitf(_wa, "Subset #%d appears more than once", i); } quit(_ok, ""); }
int main(int argc, char * argv[]) { registerTestlibCmd(argc, argv); n = inf.readInt(); // s = inf.readInt(); // for (int i = 0; i < n; i++) { // left[i] = inf.readInt(); // right[i] = inf.readInt(); // cost[i] = inf.readInt(); // } for (int i = 0; i < n; i++) { long long y1 = ans.readLong(); long long y2 = ouf.readLong(); if (y1 != y2) { quitf(_wa, "line %d: expected %s, found %s", i, vtos(y1).c_str(), vtos(y2).c_str()); } if (y1 != -1) { std::string s1; std::string s2; s1 = ans.readToken(); s2 = ouf.readToken(); if (s1 != s2) { if (s2 != "YES" && s2 != "NO") { quitf(_pe, "line %d: incorrect answer %s", i, s2.c_str()); } quitf(_wa, "line %d: expected %s, found %s", i, s1.c_str(), s2.c_str()); } } } quitf(_ok, "answer is correct"); }
int main(int argc, char * argv[]) { setName("compare two doubles, maximal absolute error = %.10lf", EPS); registerTestlibCmd(argc, argv); double ja = ans.readDouble(); double pa = ouf.readDouble(); if (fabs(ja - pa) > EPS) quitf(_wa, "expected %.10lf, found %.10lf", ja, pa); quitf(_ok, "answer is %.10lf", ja); }
int main(int argc, char * argv[]) { setName("compare two signed int%ld's", 8 * 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); }
int main(int argc, char ** argv) { registerTestlibCmd(argc, argv); int n = inf.readInt(); int c[n + 1]; c[0] = 1; c[1] = 1; for (int i = 2; i <= n; ++i) { c[i] = 0; for (int j = 0; j <= i - 1; ++j) c[i] += c[j] * c[i - 1 - j]; } int p[2][2*n]; for (int i = 0; i < c[n]; ++i) { int b = 0; for (int j = 0; j < 2 * n; ++j) { char c = ouf.readChar(); if (c != '(' && c != ')') quitf(_wa, "incorrect character in line #%d", i + 1); p[i & 1][j] = c == '(' ? -1 : 1; b += p[i & 1][j]; if (b > 0) quitf(_wa, "sequence #%d is not balanced", i + 1); } if (b != 0) quitf(_wa, "sequence #%d is not balanced", i + 1); if (i) { int j; for (j = 0; j < 2 * n && p[0][j] == p[1][j]; ++j) ; if (j == 2 * n) quitf(_wa, "sequence #%d is the same as the sequence #%d", i + 1, i); if (p[i & 1][j] < p[1 - (i & 1)][j]) quitf(_wa, "sequence #%d is less than the sequence #%d", i + 1, i); } ouf.nextLine(); } quit(_ok, ""); return 0; }
int main(int argc, char* argv[ ]) { setName("compare two sequences of doubles, max absolute or relative error = %.9f", EPS); registerTestlibCmd(argc, argv); int n = 0; double j = 0, p = 0; while (!ans.seekEof()) { n++; j = ans.readDouble(); p = ouf.readDouble(); if (!doubleCompare(j, p, EPS)) quitf(_wa, "%d%s numbers differ: expected '%.9f', found '%.9f', error '%.9f'", n, englishEnding(n).c_str(), j, p, doubleDelta(j, p) ); } if (n == 1) quitf(_ok, "found '%.9f', expected '%.9f', error '%.9f'", p, j, doubleDelta(j, p)); quitf(_ok, "%d numbers", n); }