結果

問題 No.2715 Unique Chimatagram
ユーザー 👑 kakel-sankakel-san
提出日時 2024-04-05 22:13:20
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 2,236 bytes
コンパイル時間 8,953 ms
コンパイル使用メモリ 158,472 KB
実行使用メモリ 184,708 KB
最終ジャッジ日時 2024-04-05 22:13:39
合計ジャッジ時間 15,600 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
32,804 KB
testcase_01 AC 78 ms
32,676 KB
testcase_02 AC 79 ms
32,804 KB
testcase_03 AC 79 ms
32,804 KB
testcase_04 AC 80 ms
32,804 KB
testcase_05 AC 78 ms
32,804 KB
testcase_06 AC 78 ms
32,804 KB
testcase_07 AC 80 ms
32,804 KB
testcase_08 AC 106 ms
40,100 KB
testcase_09 AC 111 ms
40,484 KB
testcase_10 AC 107 ms
40,484 KB
testcase_11 AC 105 ms
40,612 KB
testcase_12 AC 104 ms
40,356 KB
testcase_13 AC 104 ms
40,612 KB
testcase_14 AC 104 ms
40,100 KB
testcase_15 AC 105 ms
40,484 KB
testcase_16 AC 104 ms
40,228 KB
testcase_17 AC 105 ms
40,356 KB
testcase_18 AC 110 ms
40,996 KB
testcase_19 AC 103 ms
40,996 KB
testcase_20 AC 104 ms
40,996 KB
testcase_21 AC 106 ms
40,996 KB
testcase_22 AC 106 ms
40,996 KB
testcase_23 AC 106 ms
40,996 KB
testcase_24 AC 106 ms
40,996 KB
testcase_25 AC 108 ms
40,996 KB
testcase_26 AC 107 ms
40,996 KB
testcase_27 AC 110 ms
40,996 KB
testcase_28 AC 108 ms
37,924 KB
testcase_29 AC 107 ms
37,924 KB
testcase_30 AC 109 ms
37,924 KB
testcase_31 AC 108 ms
37,924 KB
testcase_32 AC 110 ms
37,924 KB
testcase_33 AC 79 ms
32,676 KB
testcase_34 AC 79 ms
32,676 KB
testcase_35 AC 78 ms
32,676 KB
testcase_36 AC 79 ms
32,804 KB
testcase_37 AC 79 ms
32,676 KB
testcase_38 AC 82 ms
32,932 KB
testcase_39 AC 100 ms
36,772 KB
testcase_40 AC 100 ms
36,516 KB
testcase_41 AC 107 ms
39,076 KB
testcase_42 AC 106 ms
184,708 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (95 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var s = SList(n);
        var ans = Chimata(n, s);
        WriteLine(ans);
    }
    static string Chimata(int n, string[] s)
    {
        var dic = new Dictionary<Data, List<int>>();
        for (var i = 0; i < n; ++i)
        {
            var counts = new int[26];
            foreach (var c in s[i]) ++counts[c - 'a'];
            for (var c = 0; c < 26; ++c)
            {
                ++counts[c];
                var data = new Data(counts);
                if (dic.ContainsKey(data)) dic[data].Add(i);
                else dic[data] = new List<int>{ i };
                --counts[c];
            }
        }
        foreach (var kv in dic)
        {
            if (kv.Value.Count == 1)
            {
                var ans = new List<char>();
                for (var c = 0; c < kv.Key.List.Length; ++c) for (var i = 0; i < kv.Key.List[c]; ++i) ans.Add((char)(c + 'a'));
                return string.Concat(ans);
            }
        }
        return "-1";
    }
    class Data
    {
        public int Key;
        public int[] List;
        public Data(int[] list)
        {
            List = (int[]) list.Clone();
            var k = 0L;
            foreach (var li in list) k = (k * 11 + li) % 1_000_000_007;
            Key = (int)k;
        }
        public override bool Equals(object obj)
        {
            var b = obj as Data;
            if (Key != b.Key) return false;
            for (var i = 0; i < List.Length; ++i) if (List[i] != b.List[i]) return false;
            return true;
        }
        public override int GetHashCode()
        {
            return Key;
        }
    }
}
0