結果
問題 | No.2102 [Cherry Alpha *] Conditional Reflection |
ユーザー | 👑 kakel-san |
提出日時 | 2022-10-14 23:57:45 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,796 bytes |
コンパイル時間 | 2,955 ms |
コンパイル使用メモリ | 72,184 KB |
実行使用メモリ | 108,680 KB |
最終ジャッジ日時 | 2023-09-09 00:53:10 |
合計ジャッジ時間 | 21,364 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 65 ms
22,524 KB |
testcase_01 | AC | 64 ms
22,652 KB |
testcase_02 | AC | 171 ms
38,088 KB |
testcase_03 | WA | - |
testcase_04 | AC | 178 ms
40,480 KB |
testcase_05 | AC | 153 ms
38,480 KB |
testcase_06 | AC | 184 ms
38,388 KB |
testcase_07 | WA | - |
testcase_08 | AC | 106 ms
27,120 KB |
testcase_09 | WA | - |
testcase_10 | AC | 118 ms
30,600 KB |
testcase_11 | AC | 110 ms
27,976 KB |
testcase_12 | AC | 157 ms
37,396 KB |
testcase_13 | WA | - |
testcase_14 | AC | 162 ms
36,956 KB |
testcase_15 | AC | 193 ms
40,064 KB |
testcase_16 | AC | 238 ms
42,084 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 130 ms
29,840 KB |
testcase_20 | WA | - |
testcase_21 | AC | 142 ms
35,316 KB |
testcase_22 | WA | - |
testcase_23 | AC | 258 ms
44,180 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 262 ms
44,220 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 258 ms
46,308 KB |
testcase_41 | WA | - |
testcase_42 | AC | 223 ms
37,576 KB |
testcase_43 | AC | 221 ms
40,032 KB |
testcase_44 | AC | 220 ms
37,720 KB |
testcase_45 | AC | 222 ms
37,476 KB |
testcase_46 | AC | 221 ms
37,536 KB |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | AC | 379 ms
106,500 KB |
testcase_53 | AC | 375 ms
108,680 KB |
testcase_54 | AC | 379 ms
106,572 KB |
testcase_55 | AC | 172 ms
28,524 KB |
testcase_56 | AC | 171 ms
30,672 KB |
testcase_57 | WA | - |
testcase_58 | AC | 238 ms
68,168 KB |
testcase_59 | AC | 252 ms
48,640 KB |
testcase_60 | AC | 106 ms
29,040 KB |
testcase_61 | AC | 172 ms
30,576 KB |
testcase_62 | AC | 71 ms
22,920 KB |
testcase_63 | AC | 106 ms
25,592 KB |
testcase_64 | AC | 104 ms
25,672 KB |
testcase_65 | AC | 107 ms
25,824 KB |
testcase_66 | AC | 167 ms
30,536 KB |
testcase_67 | AC | 156 ms
35,360 KB |
testcase_68 | AC | 155 ms
30,536 KB |
testcase_69 | AC | 155 ms
37,128 KB |
ソースコード
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; var set = new HashSet<long>[maxlen]; for (var i = 0; i < set.Length; ++i) set[i] = new HashSet<long>(); var res = new bool[n]; for (var i = 0; i < n; ++i) { var h = Hash(s[i]); var flg = false; if (set[s[i].Length - 1].Contains(h)) flg = true; for (var j = 0; j + 1 < s[i].Length; ++j) { if (flg) break; if (set[s[i].Length - 1].Contains(Swap(s[i], h, j))) flg = true; } res[i] = flg; set[s[i].Length - 1].Add(h); } 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; } }