Submission #175236
Source Code Expand
#!/usr/bin/env ruby def diff_count(str, org) cnt = 0 str_list = str.split(//) org_list = org.split(//) str_list.each_with_index do |s, i| cnt = cnt + 1 if s != org_list[i] end return cnt end def diff_count2(chars, orgs) cnt = 0 rests = chars.clone orgs.each do |org| i = rests.index(org) if i then rests.delete_at(i) else cnt = cnt + 1 end end return cnt end (n, k) = STDIN.gets.split(/ /) n = n.to_i k = k.to_i s = STDIN.gets.chomp swap = 0 len = s.size chars = s.split(//).sort s1 = '' len.times do |ind| stmp = s1 + chars[0] d1 = diff_count(stmp, s) d2 = diff_count2(chars, s[ind, len].split(//)) if d1 + d2 <= k then s1 = stmp chars.shift else c = s[ind] i = chars.index(c) if i then chars.delete_at(i) s1 = s1 + c else s1 = s1 + chars.shift end end end puts s1
Submission Info
Submission Time | |
---|---|
Task | C - 辞書式順序ふたたび |
User | mas |
Language | Ruby (1.9.3) |
Score | 0 |
Code Size | 944 Byte |
Status | WA |
Exec Time | 87 ms |
Memory | 4332 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||
Status |
|
Set Name | Test Cases |
---|---|
All | hand_1_0.txt, hand_1_1.txt, hand_1_2.txt, hand_1_3.txt, hand_1_4.txt, hand_1_5.txt, hand_1_6.txt, hand_1_7.txt, hand_1_8.txt, hand_2_0.txt, hand_2_1.txt, hand_2_10.txt, hand_2_2.txt, hand_2_3.txt, hand_2_4.txt, hand_2_5.txt, hand_2_6.txt, hand_2_7.txt, hand_2_8.txt, hand_2_9.txt, hand_3_2.txt, hand_3_3.txt, hand_3_4.txt, hand_3_5.txt, hand_3_6.txt, hand_4_2.txt, hand_4_3.txt, hand_4_4.txt, hand_4_5.txt, hand_4_6.txt, random_1.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, small_1.txt, small_2.txt, small_3.txt, small_4.txt, small_5.txt, small_6.txt, small_7.txt, small_8.txt, small_9.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
hand_1_0.txt | AC | 60 ms | 4204 KB |
hand_1_1.txt | WA | 57 ms | 4216 KB |
hand_1_2.txt | AC | 56 ms | 4196 KB |
hand_1_3.txt | WA | 62 ms | 4212 KB |
hand_1_4.txt | AC | 57 ms | 4208 KB |
hand_1_5.txt | WA | 58 ms | 4212 KB |
hand_1_6.txt | WA | 58 ms | 4128 KB |
hand_1_7.txt | AC | 58 ms | 4212 KB |
hand_1_8.txt | AC | 57 ms | 4180 KB |
hand_2_0.txt | AC | 58 ms | 4228 KB |
hand_2_1.txt | WA | 57 ms | 4212 KB |
hand_2_10.txt | AC | 57 ms | 4212 KB |
hand_2_2.txt | AC | 58 ms | 4208 KB |
hand_2_3.txt | WA | 57 ms | 4212 KB |
hand_2_4.txt | AC | 61 ms | 4212 KB |
hand_2_5.txt | WA | 58 ms | 4212 KB |
hand_2_6.txt | AC | 60 ms | 4184 KB |
hand_2_7.txt | WA | 58 ms | 4204 KB |
hand_2_8.txt | AC | 61 ms | 4212 KB |
hand_2_9.txt | AC | 58 ms | 4208 KB |
hand_3_2.txt | AC | 58 ms | 4212 KB |
hand_3_3.txt | WA | 56 ms | 4208 KB |
hand_3_4.txt | AC | 57 ms | 4208 KB |
hand_3_5.txt | WA | 59 ms | 4188 KB |
hand_3_6.txt | WA | 57 ms | 4208 KB |
hand_4_2.txt | AC | 61 ms | 4208 KB |
hand_4_3.txt | WA | 60 ms | 4216 KB |
hand_4_4.txt | AC | 60 ms | 4212 KB |
hand_4_5.txt | WA | 60 ms | 4208 KB |
hand_4_6.txt | WA | 60 ms | 4208 KB |
random_1.txt | WA | 60 ms | 4212 KB |
random_10.txt | WA | 84 ms | 4212 KB |
random_11.txt | WA | 84 ms | 4212 KB |
random_12.txt | WA | 87 ms | 4212 KB |
random_13.txt | WA | 86 ms | 4212 KB |
random_14.txt | WA | 84 ms | 4212 KB |
random_15.txt | AC | 87 ms | 4204 KB |
random_2.txt | WA | 59 ms | 4208 KB |
random_3.txt | WA | 63 ms | 4204 KB |
random_4.txt | WA | 70 ms | 4212 KB |
random_5.txt | AC | 70 ms | 4204 KB |
random_6.txt | WA | 72 ms | 4332 KB |
random_7.txt | WA | 77 ms | 4208 KB |
random_8.txt | WA | 83 ms | 4204 KB |
random_9.txt | WA | 83 ms | 4212 KB |
sample_1.txt | AC | 58 ms | 4212 KB |
sample_2.txt | WA | 65 ms | 4216 KB |
sample_3.txt | AC | 76 ms | 4188 KB |
sample_4.txt | AC | 58 ms | 4208 KB |
small_1.txt | AC | 57 ms | 4212 KB |
small_2.txt | AC | 61 ms | 4188 KB |
small_3.txt | AC | 60 ms | 4212 KB |
small_4.txt | WA | 58 ms | 4208 KB |
small_5.txt | AC | 58 ms | 4188 KB |
small_6.txt | AC | 57 ms | 4212 KB |
small_7.txt | WA | 57 ms | 4208 KB |
small_8.txt | AC | 57 ms | 4204 KB |
small_9.txt | AC | 58 ms | 4212 KB |