結果
問題 | No.1629 Sorting Integers (SUM of M) |
ユーザー | 👑 kakel-san |
提出日時 | 2024-01-25 23:14:06 |
言語 | C# (.NET 8.0.203) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,661 bytes |
コンパイル時間 | 13,751 ms |
コンパイル使用メモリ | 158,448 KB |
実行使用メモリ | 235,612 KB |
最終ジャッジ日時 | 2024-01-25 23:14:47 |
合計ジャッジ時間 | 40,346 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 81 ms
32,804 KB |
testcase_01 | AC | 79 ms
32,804 KB |
testcase_02 | AC | 79 ms
32,804 KB |
testcase_03 | AC | 295 ms
78,112 KB |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | TLE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | TLE | - |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (108 ms)。 MSBuild のバージョン 17.7.3+8ec440e68 (.NET) main -> /home/judge/data/code/bin/Release/net7.0/main.dll main -> /home/judge/data/code/bin/Release/net7.0/publish/
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var a = NList; var set = new HashSet<string>(); var list = new List<char>(); for (var i = 0; i < 9; ++i) { for (var j = 0; j < a[i]; ++j) list.Add((char)(i + '1')); } var ans = 0L; Permutate(list.ToArray(), arr => { var s = string.Concat(arr); if (set.Add(s)) ans += int.Parse(s); }); WriteLine(ans % 1_000_000_007); } static void Permutate<T>(T[] array, Action<T[]> action) { Permutate(array, 0, array.Length, action); } static void Permutate<T>(T[] array, int pos, int count, Action<T[]> action) { if (count == 0) { action(array); return; } for (var i = 0; i < count; i++) { Swap(array, pos, pos + i); Permutate(array, pos + 1, count - 1, action); Swap(array, pos, pos + i); } } static void Swap<T>(T[] array, int x, int y) { var temp = array[x]; array[x] = array[y]; array[y] = temp; } }