結果
| 問題 | No.52 よくある文字列の問題 | 
| コンテスト | |
| ユーザー |  nanophoto12 | 
| 提出日時 | 2014-10-29 00:24:56 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 27 ms / 5,000 ms | 
| コード長 | 876 bytes | 
| コンパイル時間 | 1,174 ms | 
| コンパイル使用メモリ | 108,712 KB | 
| 実行使用メモリ | 27,808 KB | 
| 最終ジャッジ日時 | 2024-09-22 05:17:42 | 
| 合計ジャッジ時間 | 2,015 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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;
using System.Collections.Generic;
using System.Globalization;
class Program
{
    public static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var charactors = s.ToCharArray();
        var head = 0;
        var tail = s.Length - 1;
        var sets = new HashSet<string>();
        Dfs(sets, charactors, head, tail, "");
        Console.WriteLine(sets.Count);
    }
    private static void Dfs(HashSet<string> sets, char[] charactors, int head, int tail, string current)
    {
        if (head == tail)
        {
            if (!sets.Contains(current))
            {
                sets.Add(current);
            }
            return;
        }
        Dfs(sets, charactors, head+1, tail, current + charactors[head]);
        Dfs(sets, charactors, head, tail-1, current + charactors[tail]);
    }
}
            
            
            
        