結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
|
提出日時 | 2023-07-25 17:48:08 |
言語 | C# (.NET 8.0.203) |
結果 |
AC
|
実行時間 | 57 ms / 5,000 ms |
コード長 | 1,793 bytes |
コンパイル時間 | 15,529 ms |
コンパイル使用メモリ | 168,204 KB |
実行使用メモリ | 184,352 KB |
最終ジャッジ日時 | 2024-10-02 11:24:18 |
合計ジャッジ時間 | 15,383 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
29,932 KB |
testcase_01 | AC | 55 ms
29,824 KB |
testcase_02 | AC | 56 ms
30,208 KB |
testcase_03 | AC | 56 ms
29,824 KB |
testcase_04 | AC | 57 ms
30,080 KB |
testcase_05 | AC | 55 ms
29,824 KB |
testcase_06 | AC | 56 ms
30,080 KB |
testcase_07 | AC | 56 ms
29,952 KB |
testcase_08 | AC | 56 ms
29,932 KB |
testcase_09 | AC | 56 ms
29,952 KB |
testcase_10 | AC | 55 ms
29,824 KB |
testcase_11 | AC | 57 ms
29,924 KB |
testcase_12 | AC | 56 ms
29,948 KB |
testcase_13 | AC | 57 ms
29,824 KB |
testcase_14 | AC | 55 ms
29,952 KB |
testcase_15 | AC | 55 ms
30,080 KB |
testcase_16 | AC | 56 ms
30,060 KB |
testcase_17 | AC | 56 ms
29,952 KB |
testcase_18 | AC | 56 ms
184,352 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (149 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using System.Collections.Generic; using System.Linq; namespace yukicoder { public class Program { public static void Main() { var n = Console.ReadLine(); var max = int.Parse(n); var k = Combination.Generate(n.Length, 2, false); foreach(var x in k) { var a = n[x[0]]; var b = n[x[1]]; var m = n.Remove(x[0], 1).Insert(x[0], b.ToString()).Remove(x[1], 1).Insert(x[1], a.ToString()); max = max < int.Parse(m) ? int.Parse(m) : max; } Console.WriteLine(max); } static class Combination { private static List<List<int>> _comb; public static List<List<int>> Generate(int n, int r, bool dupulication) { _comb = new List<List<int>>(); CalcCombination(new List<int>(), n, r, dupulication); return _comb; } private static void CalcCombination(List<int> list, int n, int r, bool dupulication) { if (list.Count == r) { _comb.Add(new List<int>(list)); return; } var index = 0; if (dupulication) { index = list.Any() ? list.Last() : 0; } else { index = list.Any() ? list.Last() + 1 : 0; } for (int i = index; i < n; i++) { list.Add(i); CalcCombination(list, n, r, dupulication); list.Remove(i); } } } } }