結果
問題 | No.52 よくある文字列の問題 |
ユーザー | kuuso1 |
提出日時 | 2014-10-28 23:58:42 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 30 ms / 5,000 ms |
コード長 | 1,629 bytes |
コンパイル時間 | 1,023 ms |
コンパイル使用メモリ | 111,780 KB |
実行使用メモリ | 25,696 KB |
最終ジャッジ日時 | 2023-10-22 03:53:59 |
合計ジャッジ時間 | 1,992 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
25,628 KB |
testcase_01 | AC | 27 ms
25,612 KB |
testcase_02 | AC | 27 ms
25,676 KB |
testcase_03 | AC | 26 ms
25,612 KB |
testcase_04 | AC | 30 ms
25,696 KB |
testcase_05 | AC | 28 ms
25,692 KB |
testcase_06 | AC | 28 ms
25,696 KB |
testcase_07 | AC | 27 ms
25,696 KB |
testcase_08 | AC | 26 ms
25,696 KB |
testcase_09 | AC | 26 ms
25,612 KB |
testcase_10 | AC | 26 ms
25,628 KB |
コンパイルメッセージ
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));} }