ncmp.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "testlib.h"
  2. using namespace std;
  3. int main(int argc, char * argv[]) {
  4. setName("compare ordered sequences of signed int%d numbers", 8 * int(sizeof(long long)));
  5. registerTestlibCmd(argc, argv);
  6. int n = 0;
  7. string firstElems;
  8. while (!ans.seekEof() && !ouf.seekEof()) {
  9. n++;
  10. long long j = ans.readLong();
  11. long long p = ouf.readLong();
  12. if (j != p)
  13. quitf(_wa, "%d%s numbers differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(), vtos(j).c_str(), vtos(p).c_str());
  14. else
  15. if (n <= 5) {
  16. if (firstElems.length() > 0)
  17. firstElems += " ";
  18. firstElems += vtos(j);
  19. }
  20. }
  21. int extraInAnsCount = 0;
  22. while (!ans.seekEof()) {
  23. ans.readLong();
  24. extraInAnsCount++;
  25. }
  26. int extraInOufCount = 0;
  27. while (!ouf.seekEof()) {
  28. ouf.readLong();
  29. extraInOufCount++;
  30. }
  31. if (extraInAnsCount > 0)
  32. quitf(_wa, "Answer contains longer sequence [length = %d], but output contains %d elements", n + extraInAnsCount, n);
  33. if (extraInOufCount > 0)
  34. quitf(_wa, "Output contains longer sequence [length = %d], but answer contains %d elements", n + extraInOufCount, n);
  35. if (n <= 5)
  36. quitf(_ok, "%d number(s): \"%s\"", n, compress(firstElems).c_str());
  37. else
  38. quitf(_ok, "%d numbers", n);
  39. }