結果

問題 No.2715 Unique Chimatagram
ユーザー 👑 kakel-sankakel-san
提出日時 2024-04-05 21:55:02
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 2,118 bytes
コンパイル時間 7,157 ms
コンパイル使用メモリ 156,536 KB
実行使用メモリ 185,372 KB
最終ジャッジ日時 2024-04-05 21:55:17
合計ジャッジ時間 13,933 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
32,932 KB
testcase_01 AC 79 ms
32,804 KB
testcase_02 AC 82 ms
33,060 KB
testcase_03 WA -
testcase_04 AC 78 ms
33,060 KB
testcase_05 AC 78 ms
33,060 KB
testcase_06 AC 78 ms
33,060 KB
testcase_07 AC 81 ms
33,060 KB
testcase_08 AC 105 ms
40,484 KB
testcase_09 WA -
testcase_10 AC 105 ms
40,740 KB
testcase_11 AC 106 ms
40,996 KB
testcase_12 AC 110 ms
40,740 KB
testcase_13 AC 105 ms
40,868 KB
testcase_14 AC 104 ms
40,356 KB
testcase_15 AC 107 ms
40,740 KB
testcase_16 AC 105 ms
40,484 KB
testcase_17 AC 104 ms
40,740 KB
testcase_18 AC 105 ms
41,252 KB
testcase_19 AC 105 ms
41,252 KB
testcase_20 AC 106 ms
41,252 KB
testcase_21 AC 106 ms
41,252 KB
testcase_22 AC 109 ms
41,252 KB
testcase_23 AC 105 ms
41,252 KB
testcase_24 AC 106 ms
41,252 KB
testcase_25 AC 105 ms
41,252 KB
testcase_26 AC 105 ms
41,252 KB
testcase_27 AC 105 ms
41,252 KB
testcase_28 AC 108 ms
38,180 KB
testcase_29 AC 108 ms
38,180 KB
testcase_30 AC 109 ms
38,180 KB
testcase_31 AC 112 ms
38,180 KB
testcase_32 AC 109 ms
38,180 KB
testcase_33 AC 79 ms
32,932 KB
testcase_34 AC 78 ms
32,804 KB
testcase_35 AC 79 ms
32,804 KB
testcase_36 AC 78 ms
33,060 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 105 ms
39,332 KB
testcase_42 AC 112 ms
185,372 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 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 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 };
            }
        }
        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'));
                WriteLine(string.Concat(ans));
                return;
            }
        }
        WriteLine(-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