about summary refs log tree commit diff
path: root/others/dict/dict.py
diff options
context:
space:
mode:
Diffstat (limited to 'others/dict/dict.py')
-rwxr-xr-xothers/dict/dict.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/others/dict/dict.py b/others/dict/dict.py
index 59724cd..76b8414 100755
--- a/others/dict/dict.py
+++ b/others/dict/dict.py
@@ -1,16 +1,12 @@
 #!/usr/bin/env python3
 
+from itertools import islice
 from bisect import bisect_left as bisect
 
-words = []
-
 
 with open('dict.inp') as fi, open('dict.out', 'w') as fo:
-    for _ in range(int(fi.readline())):
-        w = fi.readline().strip()
-        i = bisect(words, w)
-        if i == len(words) or w != words[i]:
-            words.insert(i, w)
+    words = list(islice(fi, int(fi.readline())))
+    words.sort()
 
     for _ in range(int(fi.readline())):
         s = fi.readline().strip()