Fix VNese bugs when after trimming

This commit is contained in:
Phuoc Dinh Le 2021-03-31 21:32:15 -05:00 committed by GitHub
parent ffb6797c64
commit d8e514911a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -141,16 +141,16 @@ def read_head_archive(archive, file):
with archive.open(file) as f: with archive.open(file) as f:
return f.read(settings.TESTCASE_VISIBLE_LENGTH + 3) return f.read(settings.TESTCASE_VISIBLE_LENGTH + 3)
def get_visible_content(data): def get_visible_content(data):
data = data or b'' data = data or b''
data = data.replace(b'\r\n', b'\r').replace(b'\r', b'\n') data = data.replace(b'\r\n', b'\r').replace(b'\r', b'\n')
data = data.decode('utf-8')
if (len(data) > settings.TESTCASE_VISIBLE_LENGTH): if (len(data) > settings.TESTCASE_VISIBLE_LENGTH):
data = data[:settings.TESTCASE_VISIBLE_LENGTH] data = data[:settings.TESTCASE_VISIBLE_LENGTH]
data += b'.' * 3 data += '.' * 3
elif not data.endswith(b'\n'): return data
data += b'\n'
return data.decode('utf-8')
def get_input_answer(case, archive): def get_input_answer(case, archive):