結果
問題 | No.52 よくある文字列の問題 |
ユーザー |
![]() |
提出日時 | 2014-10-28 23:58:42 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 28 ms / 5,000 ms |
コード長 | 1,629 bytes |
コンパイル時間 | 1,799 ms |
コンパイル使用メモリ | 115,040 KB |
実行使用メモリ | 27,824 KB |
最終ジャッジ日時 | 2024-09-22 05:16:13 |
合計ジャッジ時間 | 2,251 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; using System.Collections.Generic; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ S=rs(); N=S.Length; H=new HashSet<String>(); int[] route=new int[N]; for(int i=0;i<N;i++)route[i]=-1; route[0]=0; dfs(route); route[0]=N-1; dfs(route); Console.WriteLine(H.Count); } void dfs(int[] route_){ int[] route=(int[])route_.Clone(); //for(int i=0;i<N;i++)Console.Write("{0} ",route[i]);Console.WriteLine(); int l=0; int r=N-1; int now=-1; for(int i=0;i<N;i++){ if(route[i]!=-1){ now=i; if(route[i]==l)l++; if(route[i]==r)r--; } } if(now==N-1){ char[] c=new char[N]; for(int i=0;i<N;i++)c[i]=S[route[i]]; //Console.WriteLine(new String(c)); H.Add(new String(c)); return; } route[now+1]=r; dfs(route); route[now+1]=l; dfs(route); } int N; HashSet<String> H; String S; public Sol(){ } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(){return Console.ReadLine().Split(' ');} static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));} static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));} static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));} }