結果

問題 No.1909 Detect from Substrings
ユーザー 👑 kakel-sankakel-san
提出日時 2023-10-28 20:55:31
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 1,584 bytes
コンパイル時間 6,780 ms
コンパイル使用メモリ 158,684 KB
実行使用メモリ 185,716 KB
最終ジャッジ日時 2023-10-28 20:55:45
合計ジャッジ時間 13,415 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
32,692 KB
testcase_01 AC 75 ms
32,692 KB
testcase_02 AC 76 ms
32,692 KB
testcase_03 AC 76 ms
32,728 KB
testcase_04 AC 78 ms
33,300 KB
testcase_05 AC 83 ms
34,356 KB
testcase_06 AC 86 ms
35,664 KB
testcase_07 AC 86 ms
35,660 KB
testcase_08 AC 98 ms
39,552 KB
testcase_09 AC 97 ms
40,524 KB
testcase_10 AC 91 ms
38,800 KB
testcase_11 AC 89 ms
38,800 KB
testcase_12 AC 93 ms
37,924 KB
testcase_13 AC 97 ms
39,552 KB
testcase_14 AC 97 ms
39,552 KB
testcase_15 AC 99 ms
39,556 KB
testcase_16 AC 89 ms
37,932 KB
testcase_17 AC 88 ms
37,776 KB
testcase_18 AC 93 ms
36,252 KB
testcase_19 AC 95 ms
35,664 KB
testcase_20 AC 92 ms
35,660 KB
testcase_21 AC 100 ms
39,564 KB
testcase_22 AC 101 ms
39,564 KB
testcase_23 AC 97 ms
39,184 KB
testcase_24 AC 90 ms
39,180 KB
testcase_25 AC 88 ms
37,936 KB
testcase_26 AC 97 ms
39,564 KB
testcase_27 AC 101 ms
39,560 KB
testcase_28 AC 103 ms
39,560 KB
testcase_29 AC 104 ms
39,564 KB
testcase_30 AC 103 ms
39,564 KB
testcase_31 AC 100 ms
39,564 KB
testcase_32 AC 99 ms
39,564 KB
testcase_33 AC 101 ms
39,564 KB
testcase_34 AC 105 ms
39,560 KB
testcase_35 AC 102 ms
39,564 KB
testcase_36 AC 99 ms
39,560 KB
testcase_37 AC 98 ms
39,564 KB
testcase_38 AC 99 ms
185,716 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 string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var s = SList(n);
        var pt = 0;
        for (var i = 0; i < m; ++i)
        {
            if (s[0][i] != s[1][i])
            {
                pt = i;
                break;
            }
        }
        var ans = 0;
        var t1 = s[0].ToList();
        t1.Insert(pt, s[1][pt]);
        var flg = true;
        foreach (var si in s)
        {
            if (!Check(t1, si))
            {
                flg = false;
                break;
            }
        }
        if (flg) ++ans;
        var t2 = s[1].ToList();
        t2.Insert(pt, s[0][pt]);
        flg = true;
        foreach (var si in s)
        {
            if (!Check(t2, si))
            {
                flg = false;
                break;
            }
        }
        if (flg) ++ans;
        WriteLine(ans);
    }
    static bool Check(List<char> t, string s)
    {
        var pos = 0;
        for (var i = 0; i < t.Count; ++i)
        {
            if (pos < s.Length && t[i] == s[pos]) ++pos;
        }
        return pos == s.Length;
    }
}
0