1
0

ncmp.cpp 1.5 KB

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