vector<long long> readStreamCase(InStream& in, TResult pe, 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); } string numExpStr; stringstream ss; ss << testCase; ss >> numExpStr; numExpStr += ":"; 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); vector<long long> result; while (!in.seekEof()) { in.readTokenTo(token); if (token == "Case") { prereadCase = true; break; } result.push_back(stringToLongLong(in, token.c_str())); } return result; }
vector<long long> readStream(InStream& in, TResult pe) { vector<long long> result; 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); string numExpStr; stringstream ss; ss << testCase; ss >> numExpStr; numExpStr += ":"; 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); result.push_back(in.readLong()); } return result; }