結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー 👑 kakel-sankakel-san
提出日時 2022-10-14 23:47:22
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,663 bytes
コンパイル時間 2,822 ms
コンパイル使用メモリ 68,200 KB
実行使用メモリ 49,328 KB
最終ジャッジ日時 2023-09-09 00:16:42
合計ジャッジ時間 20,664 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
24,608 KB
testcase_01 AC 66 ms
24,648 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
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 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 224 ms
39,780 KB
testcase_43 AC 220 ms
39,504 KB
testcase_44 AC 225 ms
37,468 KB
testcase_45 AC 228 ms
39,744 KB
testcase_46 AC 232 ms
39,748 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 159 ms
33,644 KB
testcase_53 AC 157 ms
32,024 KB
testcase_54 AC 158 ms
33,528 KB
testcase_55 AC 173 ms
28,736 KB
testcase_56 AC 172 ms
30,612 KB
testcase_57 WA -
testcase_58 AC 157 ms
30,004 KB
testcase_59 AC 261 ms
46,680 KB
testcase_60 WA -
testcase_61 AC 172 ms
28,440 KB
testcase_62 AC 72 ms
22,840 KB
testcase_63 AC 106 ms
25,624 KB
testcase_64 AC 105 ms
25,712 KB
testcase_65 AC 108 ms
25,600 KB
testcase_66 AC 168 ms
30,620 KB
testcase_67 AC 160 ms
37,072 KB
testcase_68 AC 155 ms
30,476 KB
testcase_69 AC 158 ms
34,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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>();
        var res = new bool[n];
        for (var i = 0; i < n; ++i)
        {
            var h = Hash(s[i]);
            var flg = false;
            if (set.Contains(h)) flg = true;
            for (var j = 0; j + 1 < s[i].Length; ++j)
            {
                if (flg) break;
                if (set.Contains(Swap(s[i], h, j))) flg = true;
            }
            res[i] = flg;
            set.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;
    }
}
0