From cdbc469b1db4995bcb1a5378fdb14c20c58ba324 Mon Sep 17 00:00:00 2001 From: Nachia Vivias Date: Tue, 10 Sep 2024 11:20:53 +0900 Subject: [PATCH] value range check for checker.cpp of sqrt polynomial --- polynomial/sqrt_of_formal_power_series/checker.cpp | 5 +++-- polynomial/sqrt_of_formal_power_series_sparse/checker.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/polynomial/sqrt_of_formal_power_series/checker.cpp b/polynomial/sqrt_of_formal_power_series/checker.cpp index 81207e677..67471fc46 100644 --- a/polynomial/sqrt_of_formal_power_series/checker.cpp +++ b/polynomial/sqrt_of_formal_power_series/checker.cpp @@ -2,6 +2,7 @@ #include #include #include "testlib.h" +#include "params.h" using namespace std; using uint = unsigned int; @@ -113,12 +114,12 @@ bool has_sqrt(vector pol) { bool read_ans(InStream& stream, vector expect) { int n = int(expect.size()); - int first = stream.readInt(); + int first = stream.readInt(-1, MOD - 1); if (first == -1) return false; vector pol(n); pol[0] = first; for (int i = 1; i < n; i++) { - pol[i] = stream.readInt(); + pol[i] = stream.readInt(0, MOD - 1); } diff --git a/polynomial/sqrt_of_formal_power_series_sparse/checker.cpp b/polynomial/sqrt_of_formal_power_series_sparse/checker.cpp index bafd7c344..07dfa3665 100644 --- a/polynomial/sqrt_of_formal_power_series_sparse/checker.cpp +++ b/polynomial/sqrt_of_formal_power_series_sparse/checker.cpp @@ -2,6 +2,7 @@ #include #include #include "testlib.h" +#include "params.h" using namespace std; using uint = unsigned int; @@ -115,11 +116,11 @@ bool has_sqrt(vector pol) { bool read_ans(InStream& stream, vector expect) { int n = int(expect.size()); - int first = stream.readInt(); + int first = stream.readInt(-1, MOD - 1); if (first == -1) return false; vector pol(n); pol[0] = first; - for (int i = 1; i < n; i++) { pol[i] = stream.readInt(); } + for (int i = 1; i < n; i++) { pol[i] = stream.readInt(0, MOD - 1); } auto pol2 = multiply(pol, pol);