結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー tomeruntomerun
提出日時 2022-10-14 21:53:24
言語 Crystal
(1.11.2)
結果
RE  
実行時間 -
コード長 608 bytes
コンパイル時間 20,354 ms
コンパイル使用メモリ 255,848 KB
実行使用メモリ 131,048 KB
最終ジャッジ日時 2023-09-08 20:57:12
合計ジャッジ時間 49,653 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
88,832 KB
testcase_01 AC 89 ms
88,640 KB
testcase_02 AC 369 ms
110,956 KB
testcase_03 AC 428 ms
116,176 KB
testcase_04 AC 388 ms
111,112 KB
testcase_05 AC 341 ms
105,308 KB
testcase_06 AC 410 ms
113,188 KB
testcase_07 RE -
testcase_08 AC 243 ms
96,580 KB
testcase_09 RE -
testcase_10 AC 254 ms
99,644 KB
testcase_11 AC 189 ms
101,584 KB
testcase_12 AC 316 ms
108,308 KB
testcase_13 AC 451 ms
120,956 KB
testcase_14 AC 365 ms
108,076 KB
testcase_15 AC 482 ms
115,728 KB
testcase_16 AC 543 ms
120,400 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 280 ms
102,796 KB
testcase_20 AC 472 ms
122,872 KB
testcase_21 AC 347 ms
101,268 KB
testcase_22 AC 571 ms
125,748 KB
testcase_23 AC 574 ms
125,568 KB
testcase_24 AC 573 ms
125,544 KB
testcase_25 AC 579 ms
125,768 KB
testcase_26 AC 581 ms
124,344 KB
testcase_27 AC 572 ms
124,164 KB
testcase_28 AC 579 ms
124,140 KB
testcase_29 AC 578 ms
121,920 KB
testcase_30 AC 580 ms
125,672 KB
testcase_31 AC 572 ms
127,136 KB
testcase_32 AC 574 ms
126,560 KB
testcase_33 AC 581 ms
124,232 KB
testcase_34 AC 577 ms
125,992 KB
testcase_35 AC 577 ms
124,300 KB
testcase_36 AC 576 ms
125,756 KB
testcase_37 AC 578 ms
125,644 KB
testcase_38 AC 575 ms
122,712 KB
testcase_39 AC 580 ms
124,096 KB
testcase_40 AC 578 ms
124,148 KB
testcase_41 AC 581 ms
124,200 KB
testcase_42 AC 416 ms
111,940 KB
testcase_43 AC 399 ms
111,748 KB
testcase_44 AC 394 ms
112,308 KB
testcase_45 AC 386 ms
112,108 KB
testcase_46 AC 382 ms
112,392 KB
testcase_47 AC 378 ms
124,804 KB
testcase_48 AC 373 ms
127,244 KB
testcase_49 AC 383 ms
125,964 KB
testcase_50 AC 371 ms
126,040 KB
testcase_51 AC 374 ms
125,564 KB
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 AC 105 ms
94,144 KB
testcase_59 AC 576 ms
131,048 KB
testcase_60 AC 244 ms
96,948 KB
testcase_61 RE -
testcase_62 AC 99 ms
90,092 KB
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 AC 377 ms
110,220 KB
testcase_68 AC 110 ms
94,136 KB
testcase_69 AC 378 ms
108,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD  = 99999999999999997u64
MUL  =                   31
MULS = [1u64]
1000000.times do
  MULS << MULS[-1] * MUL % MOD
end
n = read_line.to_i
hs = Array.new(1000001) { Set(UInt64).new }

n.times do
  s = read_line.chars
  h = 0u64
  s.size.times do |i|
    h += MULS[i] * s[i].ord
    h %= MOD
  end
  puts hs[s.size].includes?(h) ? "Yes" : "No"
  hs[s.size] << h
  (s.size - 1).times do |i|
    next if s[i] == s[i + 1]
    h2 = h + MULS[i + 1] * s[i].ord + MULS[i] * s[i + 1].ord
    h2 += MOD - MULS[i] * s[i].ord % MOD
    h2 += MOD - MULS[i + 1] * s[i + 1].ord % MOD
    hs[s.size] << h2 % MOD
  end
end
0