結果
問題 | No.2708 Jewel holder |
ユーザー | bluemegane |
提出日時 | 2024-04-04 06:55:22 |
言語 | C# (.NET 8.0.203) |
結果 |
AC
|
実行時間 | 78 ms / 2,000 ms |
コード長 | 2,097 bytes |
コンパイル時間 | 18,823 ms |
コンパイル使用メモリ | 158,880 KB |
実行使用メモリ | 179,824 KB |
最終ジャッジ日時 | 2024-04-04 06:55:45 |
合計ジャッジ時間 | 22,450 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 59 ms
31,524 KB |
testcase_01 | AC | 61 ms
31,524 KB |
testcase_02 | AC | 59 ms
31,524 KB |
testcase_03 | AC | 60 ms
31,524 KB |
testcase_04 | AC | 59 ms
31,524 KB |
testcase_05 | AC | 59 ms
31,524 KB |
testcase_06 | AC | 59 ms
31,524 KB |
testcase_07 | AC | 59 ms
31,524 KB |
testcase_08 | AC | 59 ms
31,524 KB |
testcase_09 | AC | 58 ms
31,524 KB |
testcase_10 | AC | 59 ms
31,524 KB |
testcase_11 | AC | 59 ms
31,524 KB |
testcase_12 | AC | 59 ms
31,524 KB |
testcase_13 | AC | 62 ms
31,524 KB |
testcase_14 | AC | 61 ms
31,524 KB |
testcase_15 | AC | 61 ms
31,652 KB |
testcase_16 | AC | 61 ms
31,524 KB |
testcase_17 | AC | 78 ms
37,668 KB |
testcase_18 | AC | 64 ms
33,060 KB |
testcase_19 | AC | 63 ms
179,824 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (104 ms)。 MSBuild のバージョン 17.7.3+8ec440e68 (.NET) /home/judge/data/code/Main.cs(32,14): warning CS8981: 型名 'hello' には、小文字の ASCII 文字のみが含まれています。このような名前は、プログラミング言語用に予約されている可能性があります。 [/home/judge/data/code/main.csproj] main -> /home/judge/data/code/bin/Release/net7.0/main.dll main -> /home/judge/data/code/bin/Release/net7.0/publish/
ソースコード
using System.Collections.Generic; using System; class Perm { public static void Swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; } public static bool NextPermutation<T>(T[] array, int index, int length, Comparison<T> comp) { if (length <= 1) return false; for (int i = length - 1; i > 0; i--) { int k = i - 1; if (comp(array[k], array[i]) < 0) { int j = Array.FindLastIndex(array, delegate (T x) { return comp(array[k], x) < 0; }); Swap(ref array[k], ref array[j]); Array.Reverse(array, i, length - i); return true; } } Array.Reverse(array, index, length); return false; } public static bool NextPermutation<T>(T[] array) where T : IComparable { return NextPermutation(array, 0, array.Length, Comparer<T>.Default.Compare); } } public class hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var h = int.Parse(line[0]); var w = int.Parse(line[1]); var map = new char[h, w]; for (int i = 0; i < h; i++) { var s = Console.ReadLine().Trim(); for (int j = 0; j < w; j++) map[i, j] = s[j]; } getAns(h, w, map); } static bool check(char[,] map, int[] a) { var x = 0; var y = 0; var jw = 1; foreach (var z in a) { if (z == 0) x++; else y++; if (map[x, y] == 'o') jw++; else if (map[x, y] == 'x') { jw--; if (jw < 0) return false; } else return false; } return true; } static void getAns(int h, int w, char[,] map) { var a = new int[h + w - 2]; var c = 0; for (int i = h - 1; i < h + w - 2; i++) a[i] = 1; do { if (check(map, a)) c++; } while (Perm.NextPermutation(a)); Console.WriteLine(c); } }