#include "testlib.h"
#include <cmath>

int main(int argc, char* argv[]) {
    setName("Compare two sequences of doubles, max absolute/relative error = 1e-6");
    registerTestlibCmd(argc, argv);

    int line = 0;
    while (!ans.seekEof() && !ouf.seekEof()) {
        ++line;
        double jans = ans.readDouble();
        double pans = ouf.readDouble();

        // 使用 testlib 自带的 doubleCompare 比较，允许 1e-6 的绝对/相对误差
        if (!doubleCompare(jans, pans, 1e-6)) {
            quitf(_wa, "Line %d: expected %.10f, found %.10f", line, jans, pans);
        }
    }

    // 检查是否行数一致
    if (!ans.seekEof() || !ouf.seekEof()) {
        quitf(_wa, "Number of lines differ");
    }

    quitf(_ok, "All answers are within 1e-6 tolerance");
    return 0;
}
