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
/
0006.html
183 lines (182 loc) · 10.4 KB
/
0006.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<div>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="Word.Document" name="ProgId">
<meta content="Microsoft Word 11" name="Generator">
<meta content="Microsoft Word 11" name="Originator">
<link href="file:///C:%5CDOCUME%7E1%5CTOP%7E1.GEN%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" rel="File-List" /><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:PunctuationKerning />
<w:ValidateAgainstSchemas />
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:BreakWrappedTables />
<w:SnapToGridInCell />
<w:ApplyBreakingRules />
<w:WrapTextWithPunct />
<w:UseAsianBreakRules />
<w:DontGrowAutofit />
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><style type="text/css">
<!--
/* Font Definitions */
@font-face
{font-family:"Angsana New";
panose-1:2 2 6 3 5 4 5 2 3 4;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:16777219 0 0 0 65537 0;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:1627421319 -2147483648 8 0 66047 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
mso-bidi-font-size:14.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
mso-bidi-font-family:"Angsana New";}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:555822323;
mso-list-template-ids:1145621148;}
@list l0:level1
{mso-level-tab-stop:54.0pt;
mso-level-number-position:left;
margin-left:54.0pt;
text-indent:-18.0pt;}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:90.0pt;
mso-level-number-position:left;
margin-left:90.0pt;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:"Courier New";}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
-->
</style><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:ตารางปกติ;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]--> </meta>
</meta>
</meta>
</meta>
</div>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="Word.Document" name="ProgId">
<meta content="Microsoft Word 11" name="Generator">
<meta content="Microsoft Word 11" name="Originator">
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Tahoma;"> Soundex <span lang="TH">เป็นอัลกอริธึมสำหรับเข้ารหัสชื่อต่างๆ ตามการออกเสียงในภาษาอังกฤษ โดยชื่อที่มีการออกเสียงเหมือนกันจะมีรหัส</span> Soundex<span lang="TH"> เดียวกัน แม้ว่าจะสะกดต่างกันก็ตาม ดังนั้นคำว่า</span> "Programming" <span lang="TH">จะมีรหัส</span> Soundex<span lang="TH"> เดียวกับ</span> "Porokeremon" <span lang="TH">คือ </span>P626</span></span><o:p><span style="font-size: small;"><span style="font-family: Tahoma;"><br />
</span></span></o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Tahoma;"><span lang="TH"> รหัส</span> Soundex <span lang="TH">ประกอบด้วยอักษรหนึ่งตัวตามด้วยตัวเลขอีกสามตัว ตัวอักษรตัวแรกก็คือตัวอักษรตัวแรกของชื่อ ส่วนตัวเลขได้มาจากการเข้ารหัสพยัญชนะที่เหลือ โดยพยัญชนะที่มีเสียงคล้ายกันจะใช้เลขรหัสเดียวกัน สระ</span><span lang="TH">สามารถมีผลต่อรหัสได้ แต่จะไม่ถูกรวมเข้าไปในรหัส ยกเว้นในกรณีที่เป็นตัวอักษรตัวแรก</span></span></span></p>
<p class="MsoNormal"><o:p></o:p><u><strong><o:p></o:p></strong><o:p></o:p><span style="font-size: small;"><span style="font-family: Tahoma;"><span lang="TH"><br />
ขั้นตอนการเข้ารหัส</span></span></span></u><span lang="TH" style="font-size: 14pt;" angsana="" new=""><o:p></o:p></span><span style="font-size: small;"><span style="font-family: Tahoma;"><!--[if !supportLists]--><span lang="TH"><br />
</span></span></span></p>
<ol>
<li><span style="font-size: small;"><span style="font-family: Tahoma;"><span lang="TH">เปลี่ยนพยัญชนะทั้งหมด(ยกเว้นตัวอักษรตัวแรก) ให้เป็นตัวเลข ดังนี้</span></span></span>
<ul>
<li>b, f, p, v => 1</li>
<li><span style="font-size: small;"><span style="font-family: Tahoma;">c, g, j, k, q, s, x, z => 2</span></span><span style="font-family: Tahoma;"><o:p></o:p></span></li>
<li><span style="font-size: small;"><span style="font-family: Tahoma;"><!--[if !supportLists]--><span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span><!--[endif]-->d, t => 3</span></span><span style="font-family: Tahoma;"><o:p></o:p></span></li>
<li><span style="font-size: small;"><span style="font-family: Tahoma;"><!--[endif]-->l => 4</span></span></li>
<li><span style="font-size: small;"><span style="font-family: Tahoma;"><!--[if !supportLists]--><!--[endif]-->m, n => 5</span></span></li>
<li><span style="font-size: small;"><span style="font-family: Tahoma;"><span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span><!--[endif]-->r => 6</span></span></li>
</ul>
</li>
<li><span style="font-size: small;"><span style="font-family: Tahoma;"><!--[endif]--><span lang="TH">ยุบตัวเลขซ้ำกันที่อยู่ติดกัน ให้เหลือตัวเลขนั้นตัวเดียว</span></span></span></li>
<li><span style="font-size: small;"><span style="font-family: Tahoma;"><span lang="TH">ลบตัวอักษรที่ไม่ใช่ตัวเลขทิ้งทั้งหมด ยกเว้นตัวอักษรตัวแรก</span></span></span><span style="font-family: Tahoma;"><o:p></o:p></span></li>
<li><span style="font-size: small;"><span style="font-family: Tahoma;"><!--[if !supportLists]--><!--[endif]--><span lang="TH">รหัส</span> Soundex<span lang="TH"> ที่ได้จะเป็นตัวอักษรตัวแรก และตัวเลขสามตัวที่เหลือ ถ้ามีตัวเลขไม่ครบสามตัว เติมเลขศูนย์ต่อท้ายจนครบ</span></span></span><span lang="TH" style="font-size: 14pt;" angsana="" new=""> <o:p></o:p></span></li>
</ol>
<div><strong><br />
โจทย์</strong></div>
จงเปรียบเทียบชื่อสองชื่อที่กำหนดให้ว่าออกเสียงเหมือนกันหรือไม่ กล่าวคือมีรหัส Soundex เดียวกันหรือไม่<br />
<br />
<strong>ข้อมูลนำเข้า</strong><br />
<u>บรรทัดแรก</u> จำนวนเต็ม N (1 <= N <= 100 000) เป็นจำนวนคู่ของชื่อที่ต้องการทดสอบ<br />
<u>บรรทัดถัดไปอีก N บรรทัด</u> ประกอบด้วยชื่อสองชื่อคั่นด้วยช่องว่าง <br />
โดย ชื่อ หมายถึงข้อความที่ประกอบด้วยตัวอักษรภาษาอังกฤษ (a-z, A-Z) ความยาวไม่เกิน 100 ตัวอักษร<br />
<strong><br />
ข้อมูลส่งออก</strong><br />
มี N บรรทัด แต่ละบรรทัดแสดงผลการเปรียบเทียบของแต่ละคู่ตามลำดับ โดยให้แสดงรหัส Soundex ที่เท่ากัน หรือคำว่า "NO" ถ้าชื่อคู่นั้นมีรหัส Soundex ไม่ตรงกัน<br />
<br />
<strong>ที่มา: </strong> Programming.in.th<strong><br />
อ้างอิง: </strong>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="Word.Document" name="ProgId">
<meta content="Microsoft Word 11" name="Generator">
<meta content="Microsoft Word 11" name="Originator"><a href="http://en.wikipedia.org/wiki/Soundex">http://en.wikipedia.org/wiki/Soundex</a> </meta>
</meta>
</meta>
</meta>
</meta>
</meta>
</meta>
</meta>
<table>
<tr>
<th>ข้อมูลนำเข้า</th>
<th>ข้อมูลส่งออก</th>
</tr>
<tr>
<td>3
<br />Programming Pokemon
<br />Robert Rupert
<br />Rupert Rubin</td>
<td>NO
<br />R150
<br />NO</td>
</tr>
<tr>
<td>2
<br />Programming Porokeremon
<br />Kaaa Kaaw
<br /></td>
<td>P626
<br />K000</td>
</tr></table>