This repository has been archived by the owner on Apr 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1000.html
40 lines (39 loc) · 3.25 KB
/
1000.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<span style="font-family: Courier New"><strong>โซ่คำ </strong>คือลำดับของคำที่มีจำนวนอักขระเท่ากันและแต่ละคำที่มีลำดับติดกันจะต้องมีตำแหน่งที่มีตัวอักขระต่างกันไม่เกินสองตำแหน่ง เช่น HEAD และ HEAP จะต่างกันตำแหน่งเดียวคือ D และ P ในตำแหน่งตัวอักขระที่ 4 ของคำ ในขณะที่ REAR กับ BAER จะมีตำแหน่งต่างกัน 3 ตำแหน่ง คือ ตำแหน่งที่ 1 (R กับ B) ตำแหน่งที่ 2 (E และ A) และ ตำแหน่งที่ 3 (A และ E) <br />
<br />
<strong>ตัวอย่างของโซ่คำที่ต่อเนื่อง</strong>ได้แก่ HEAD HEAP LEAP TEAR REAR และ EGG EAG GAE GAP TAP TIN<br />
<strong>ตัวอย่างของโซ่คำที่ขาด</strong>ได้แก่ LEAP TEAR REAR BAER BAET BEEP ซึ่งจะขาดที่ คำว่า BAER<br />
<br />
ให้ชุดของโซ่คำมาชุดหนึ่ง จงเขียนโปรแกรม<strong>เพื่อหาคำสุดท้ายในโซ่คำ </strong>ก่อนที่โซ่คำจะขาด<br />
<br />
<u><strong>ข้อมูลนำเข้า</strong></u><br />
<strong>บรรทัดแรก </strong>เก็บจำนวนเต็ม L แทนจำนวนตัวอักษรของแต่ละคำ โดยที่ 3 <= L <= 1000 <br />
<strong>บรรทัดที่สอง</strong> เก็บจำนวนเต็ม N แทนจำนวนคำทั้งหมดในแฟ้มข้อมูล โดยที่ 1 <= N <= 30000 <br />
<strong>บรรทัดที่ 3..(N +2)</strong> เก็บลำดับของคำที่มีจำนวนตัวอักขระ L ตัว แต่ละบรรทัดเก็บคำที่เขียนด้วยตัวอักษร (‘A’ ถึง ‘Z’ ) ที่เป็นตัวพิมพ์ใหญ่<br />
<br />
<u><strong>ข้อมูลส่งออก</strong></u><br />
แฟ้มผลลัพธ์ มี 1 บรรทัด เก็บคำสุดท้ายของโซ่คำชุดแรก<br />
<br />
<u><strong>ที่มา</strong></u><strong>: การแข่งขันคอมพิวเตอร์โอลิมปิก สอวน. ครั้งที่ 1 มหาวิทยาลัยเกษตรศาสตร์</strong><br type="_moz" />
</span>
<table>
<tr>
<th>ข้อมูลนำเข้า</th>
<th>ข้อมูลส่งออก</th>
</tr>
<tr>
<td>4
<br />12
<br />HEAD
<br />HEAP
<br />LEAP
<br />TEAR
<br />REAR
<br />BAER
<br />BAET
<br />BEEP
<br />JEEP
<br />JOIP
<br />JEIP
<br />AEIO</td>
<td>REAR</td>
</tr></table>