結果
| 問題 | No.52 よくある文字列の問題 | 
| コンテスト | |
| ユーザー |  bluemegane | 
| 提出日時 | 2018-10-08 09:12:33 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 28 ms / 5,000 ms | 
| コード長 | 1,123 bytes | 
| コンパイル時間 | 919 ms | 
| コンパイル使用メモリ | 111,560 KB | 
| 実行使用メモリ | 28,780 KB | 
| 最終ジャッジ日時 | 2024-09-22 05:36:42 | 
| 合計ジャッジ時間 | 1,709 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 11 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Collections.Generic;
using System.Linq;
using System;
public class P
{
    public string s { get; set; }
    public string t { get; set; }
}
public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var ans = getAns(s);
        Console.WriteLine(ans);
    }
    public static int getAns(string s)
    {
        var sL = s.Length;
        if (sL == 1) return 1;
        var ts = new List<string>();
        var q = new Queue<P>();
        q.Enqueue(new P { s = s.Substring(1), t = "" + s[0] });
        q.Enqueue(new P { s  = s.Substring(0,sL -1), t = "" + s[sL -1] });
        while (q.Count() > 0)
        {
            var w = q.Dequeue();
            if (w.s == "") { ts.Add(w.t); continue; }
            if (w.s.Length == 1) q.Enqueue(new P { s = "", t = w.t + w.s });
            else
            {
                q.Enqueue(new P { s = w.s.Substring(1), t = w.t + w.s[0] });
                q.Enqueue(new P { s = w.s.Substring(0, w.s.Length - 1), t = w.t + w.s[w.s.Length - 1] });
            }
        }
        return  ts.Distinct().Count();
    }
}
            
            
            
        