結果
問題 | No.506 限られたジャパリまん |
ユーザー | mban |
提出日時 | 2017-04-28 19:26:10 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,738 bytes |
コンパイル時間 | 2,225 ms |
コンパイル使用メモリ | 105,892 KB |
実行使用メモリ | 31,968 KB |
最終ジャッジ日時 | 2023-09-10 12:54:10 |
合計ジャッジ時間 | 6,294 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
20,788 KB |
testcase_01 | AC | 61 ms
20,768 KB |
testcase_02 | AC | 60 ms
18,784 KB |
testcase_03 | AC | 58 ms
18,760 KB |
testcase_04 | AC | 67 ms
20,804 KB |
testcase_05 | AC | 61 ms
18,680 KB |
testcase_06 | AC | 61 ms
20,924 KB |
testcase_07 | AC | 64 ms
20,796 KB |
testcase_08 | AC | 383 ms
24,920 KB |
testcase_09 | AC | 213 ms
25,016 KB |
testcase_10 | AC | 65 ms
20,640 KB |
testcase_11 | AC | 334 ms
26,960 KB |
testcase_12 | AC | 224 ms
26,836 KB |
testcase_13 | AC | 61 ms
18,680 KB |
testcase_14 | AC | 63 ms
20,800 KB |
testcase_15 | AC | 62 ms
22,752 KB |
testcase_16 | AC | 306 ms
24,776 KB |
testcase_17 | AC | 69 ms
20,776 KB |
testcase_18 | AC | 70 ms
20,812 KB |
testcase_19 | AC | 97 ms
24,952 KB |
testcase_20 | AC | 128 ms
30,912 KB |
testcase_21 | AC | 77 ms
23,452 KB |
testcase_22 | AC | 141 ms
31,968 KB |
testcase_23 | AC | 111 ms
28,084 KB |
testcase_24 | WA | - |
コンパイルメッセージ
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; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; public class Program { public static void Main(string[] args) { new Magatro().Solve(); } } class Magatro { private int H, W, K, P; private int[] x, y; private string[] N; private void Scan() { string[] line = Console.ReadLine().Split(' '); H = int.Parse(line[0]); W = int.Parse(line[1]); K = int.Parse(line[2]); P = int.Parse(line[3]); x = new int[K]; y = new int[K]; N = new string[K]; for (int i = 0; i < K; i++) { line = Console.ReadLine().Split(' '); x[i] = int.Parse(line[0]); y[i] = int.Parse(line[1]); N[i] = line[2]; } } public void Solve() { Scan(); long max = -1; int ans = 0; for (int i = 0; i < (1 << K); i++) { if (BitCount(i) != P) { continue; } long cnt = Count(i); if (max < cnt) { ans = i; max = cnt; } } Console.WriteLine(max%((int)1e9+7)); for (int i = 0; i < K; i++) { int j = 1 << i; if ((ans & j) != 0) { Console.WriteLine(N[i]); } } } private long Count(int i) { var d = new Dictionary<Pair<int, int>, bool>(); for (int j = 0; j < K; j++) { int k = 1 << j; if ((i & k) == 0) { d[new Pair<int, int>(x[j], y[j])] = true; } } var dp = new long[H + 1, W + 1]; dp[0, 0] = 1; for (int j = 0; j <= H; j++) { for (int k = 0; k <= W; k++) { bool o; if (d.TryGetValue(new Pair<int, int>(j, k), out o)) continue; if (j < H) { dp[j + 1, k] += dp[j, k]; } if (k < W) { dp[j, k + 1] += dp[j, k]; } } } return dp[H, W]; } private int BitCount(int n) { int cnt = 0; for (int i = 0; i < K; i++) { if (n % 2 == 1) { cnt++; } n /= 2; } return cnt; } } struct Pair<F, S> { public F First; public S Second; public Pair(F f, S s) { First = f; Second = s; } }