結果
問題 | No.170 スワップ文字列(Easy) |
ユーザー |
![]() |
提出日時 | 2015-03-22 23:36:07 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 1,329 bytes |
コンパイル時間 | 1,030 ms |
コンパイル使用メモリ | 117,036 KB |
実行使用メモリ | 21,760 KB |
最終ジャッジ日時 | 2024-12-23 00:15:29 |
合計ジャッジ時間 | 2,534 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
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(){var Ca=rs().ToCharArray();Array.Sort(Ca);int cnt=0;do{cnt++;}while(NextPermutaion(Ca));Console.WriteLine(cnt-1);}public Sol(){}static public bool NextPermutaion<T>(T[] A)where T:IComparable<T>{for(int i=A.Length-2;i>=0;i--){if(A[i].CompareTo(A[i+1])<0){int trgt=Array.FindLastIndex(A,x=>A[i].CompareTo(x)<0);Swap(ref A[i],ref A[trgt]);Array.Reverse(A,i+1,A.Length-(i+1));return true;}}Array.Reverse(A);return false;}static void Swap<T>(ref T x, ref T y){T t=x;x=y;y=t;}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));}}