結果
問題 | No.2102 [Cherry Alpha *] Conditional Reflection |
ユーザー | kakel-san |
提出日時 | 2022-10-15 00:22:37 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 902 ms / 3,000 ms |
コード長 | 2,960 bytes |
コンパイル時間 | 5,322 ms |
コンパイル使用メモリ | 109,056 KB |
実行使用メモリ | 215,660 KB |
最終ジャッジ日時 | 2024-06-26 18:26:54 |
合計ジャッジ時間 | 30,339 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
19,328 KB |
testcase_01 | AC | 34 ms
19,200 KB |
testcase_02 | AC | 217 ms
40,320 KB |
testcase_03 | AC | 249 ms
42,552 KB |
testcase_04 | AC | 222 ms
40,448 KB |
testcase_05 | AC | 159 ms
37,504 KB |
testcase_06 | AC | 233 ms
41,216 KB |
testcase_07 | AC | 223 ms
34,688 KB |
testcase_08 | AC | 89 ms
24,832 KB |
testcase_09 | AC | 239 ms
39,616 KB |
testcase_10 | AC | 115 ms
29,440 KB |
testcase_11 | AC | 106 ms
28,800 KB |
testcase_12 | AC | 187 ms
39,424 KB |
testcase_13 | AC | 298 ms
48,816 KB |
testcase_14 | AC | 183 ms
39,296 KB |
testcase_15 | AC | 256 ms
44,184 KB |
testcase_16 | AC | 335 ms
50,980 KB |
testcase_17 | AC | 154 ms
28,928 KB |
testcase_18 | AC | 263 ms
39,168 KB |
testcase_19 | AC | 137 ms
33,408 KB |
testcase_20 | AC | 313 ms
49,336 KB |
testcase_21 | AC | 146 ms
32,000 KB |
testcase_22 | AC | 414 ms
53,288 KB |
testcase_23 | AC | 408 ms
53,152 KB |
testcase_24 | AC | 397 ms
52,864 KB |
testcase_25 | AC | 386 ms
53,300 KB |
testcase_26 | AC | 404 ms
53,408 KB |
testcase_27 | AC | 409 ms
53,436 KB |
testcase_28 | AC | 412 ms
52,796 KB |
testcase_29 | AC | 391 ms
52,756 KB |
testcase_30 | AC | 469 ms
53,264 KB |
testcase_31 | AC | 444 ms
53,324 KB |
testcase_32 | AC | 388 ms
52,608 KB |
testcase_33 | AC | 431 ms
52,776 KB |
testcase_34 | AC | 474 ms
53,148 KB |
testcase_35 | AC | 388 ms
53,152 KB |
testcase_36 | AC | 376 ms
53,056 KB |
testcase_37 | AC | 374 ms
53,040 KB |
testcase_38 | AC | 394 ms
53,432 KB |
testcase_39 | AC | 377 ms
52,480 KB |
testcase_40 | AC | 378 ms
53,308 KB |
testcase_41 | AC | 386 ms
53,136 KB |
testcase_42 | AC | 286 ms
39,564 KB |
testcase_43 | AC | 287 ms
39,692 KB |
testcase_44 | AC | 289 ms
39,560 KB |
testcase_45 | AC | 285 ms
39,692 KB |
testcase_46 | AC | 291 ms
39,428 KB |
testcase_47 | AC | 240 ms
31,360 KB |
testcase_48 | AC | 240 ms
31,488 KB |
testcase_49 | AC | 241 ms
31,232 KB |
testcase_50 | AC | 237 ms
31,616 KB |
testcase_51 | AC | 242 ms
31,616 KB |
testcase_52 | AC | 875 ms
215,372 KB |
testcase_53 | AC | 902 ms
215,496 KB |
testcase_54 | AC | 877 ms
215,660 KB |
testcase_55 | AC | 195 ms
24,704 KB |
testcase_56 | AC | 198 ms
24,448 KB |
testcase_57 | AC | 198 ms
24,832 KB |
testcase_58 | AC | 527 ms
123,156 KB |
testcase_59 | AC | 378 ms
55,856 KB |
testcase_60 | AC | 95 ms
24,576 KB |
testcase_61 | AC | 199 ms
24,576 KB |
testcase_62 | AC | 41 ms
19,584 KB |
testcase_63 | AC | 95 ms
23,040 KB |
testcase_64 | AC | 96 ms
23,168 KB |
testcase_65 | AC | 96 ms
23,296 KB |
testcase_66 | AC | 189 ms
24,576 KB |
testcase_67 | AC | 162 ms
31,488 KB |
testcase_68 | AC | 179 ms
24,832 KB |
testcase_69 | AC | 161 ms
31,488 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static string[] SList(int n) => Enumerable.Repeat(0, n).Select(_ => ReadLine()).ToArray(); static void Main() { Solve(); } static void Solve() { var n = NN; var s = SList(n); WriteLine(Ref(n, s)); } static string Ref(int n, string[] s) { var maxlen = s.Max(si => si.Length); mul = new long[maxlen]; mul[0] = 1; for (var i = 1; i < mul.Length; ++i) mul[i] = mul[i - 1] * 31 % mod; mul2 = new long[maxlen]; mul2[0] = 2; for (var i = 1; i < mul2.Length; ++i) mul2[i] = mul2[i - 1] * 41 % mod2; var set = new Dictionary<long, string>[maxlen]; for (var i = 0; i < set.Length; ++i) set[i] = new Dictionary<long, string>(); var set2 = new Dictionary<long, string>[maxlen]; for (var i = 0; i < set2.Length; ++i) set2[i] = new Dictionary<long, string>(); var res = new bool[n]; for (var i = 0; i < n; ++i) { var h = Hash(s[i]); var h2 = Hash2(s[i]); var flg = false; var len = s[i].Length - 1; if (set[len].ContainsKey(h) && set2[len].ContainsKey(h2)) { if (set[len][h] == set2[len][h2]) flg = true; } for (var j = 0; j + 1 < s[i].Length; ++j) { if (flg) break; var sw1 = Swap(s[i], h, j); var sw2 = Swap2(s[i], h2, j); if (set[len].ContainsKey(sw1) && set2[len].ContainsKey(sw2)) { if (set[len][sw1] == set2[len][sw2]) flg = true; } } res[i] = flg; set[len][h] = s[i]; set2[len][h2] = s[i]; } return string.Join("\n", res.Select(f => f ? "Yes" : "No")); } static int mod = 1_000_000_009; static long[] mul = new long[0]; static long Hash(string a) { var res = 0L; for (var i = 0; i < a.Length; ++i) res = (res + (a[i] - 'a') * mul[i]) % mod; return res; } static long Swap(string a, long hash, int pos) { return (hash + (a[pos + 1] - a[pos] + mod) * mul[pos] % mod + (a[pos] - a[pos + 1] + mod) * mul[pos + 1] % mod) % mod; } static int mod2 = 1_110_000_019; static long[] mul2 = new long[0]; static long Hash2(string a) { var res = 0L; for (var i = 0; i < a.Length; ++i) res = (res + (a[i] - 'a') * mul2[i]) % mod2; return res; } static long Swap2(string a, long hash, int pos) { return (hash + (a[pos + 1] - a[pos] + mod2) * mul2[pos] % mod2 + (a[pos] - a[pos + 1] + mod2) * mul2[pos + 1] % mod2) % mod2; } }