From 874fbaa739eae1781e90f01178981b399efa79f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A0=9C=ED=9D=AC?= <103947888+pinkkj@users.noreply.github.com> Date: Tue, 2 Dec 2025 00:46:00 +0900 Subject: [PATCH] =?UTF-8?q?251201=20:=20[BOJ=206137]=20=EB=AC=B8=EC=9E=90?= =?UTF-8?q?=EC=97=B4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _jehui/6137.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 _jehui/6137.py diff --git a/_jehui/6137.py b/_jehui/6137.py new file mode 100644 index 00000000..dc69f591 --- /dev/null +++ b/_jehui/6137.py @@ -0,0 +1,50 @@ +N = int(input()) +result = [] +sen = [] +for _ in range(N): + sen.append(input()) +start = 0 +end = -1 +check = 0 +while True: + if (start-N) == end: + result.append(sen[start]) + check += 1 + break + + if sen[start] > sen[end]: + result.append(sen[end]) + check += 1 + end -= 1 + elif sen[start] < sen[end]: + result.append(sen[start]) + check += 1 + start += 1 + else: + tmp_start = start + tmp_end = end + no_problem = False + while sen[tmp_start] == sen[tmp_end]: + tmp_start += 1 + tmp_end -= 1 + if tmp_start >= (tmp_end+N): + no_problem = True + break + if no_problem: + result.append(sen[start]) + check += 1 + start += 1 + else: + if sen[tmp_start] > sen[tmp_end]: + result.append(sen[end]) + check += 1 + end -= 1 + elif sen[tmp_start] < sen[tmp_end]: + result.append(sen[start]) + check += 1 + start += 1 + + if check % 80 == 0: + result.append("\n") + check = 0 +print("".join(result)) \ No newline at end of file