結果
問題 | No.506 限られたジャパリまん |
ユーザー | mban |
提出日時 | 2017-04-21 23:17:10 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,987 bytes |
コンパイル時間 | 2,302 ms |
コンパイル使用メモリ | 108,592 KB |
実行使用メモリ | 26,832 KB |
最終ジャッジ日時 | 2023-09-10 12:52:18 |
合計ジャッジ時間 | 5,166 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 58 ms
20,804 KB |
testcase_01 | AC | 58 ms
22,652 KB |
testcase_02 | AC | 58 ms
20,828 KB |
testcase_03 | AC | 58 ms
20,808 KB |
testcase_04 | WA | - |
testcase_05 | AC | 63 ms
20,784 KB |
testcase_06 | AC | 57 ms
20,776 KB |
testcase_07 | WA | - |
testcase_08 | AC | 110 ms
24,888 KB |
testcase_09 | AC | 81 ms
24,776 KB |
testcase_10 | AC | 59 ms
20,736 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 59 ms
22,784 KB |
testcase_14 | WA | - |
testcase_15 | AC | 59 ms
22,780 KB |
testcase_16 | AC | 101 ms
26,832 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 66 ms
20,820 KB |
コンパイルメッセージ
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; using System.IO; class Program { static void Main(string[] args) { new Magatro().Solve(); } } public class Scanner { private StreamReader Sr; private string[] S; private int Index; private const char Separator = ' '; public Scanner(Stream source) { Index = 0; S = new string[0]; Sr = new StreamReader(source); } private string[] Line() { return Sr.ReadLine().Split(Separator); } public string Next() { string result; if (Index >= S.Length) { S = Line(); Index = 0; } result = S[Index]; Index++; return result; } public int NextInt() { return int.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public decimal NextDecimal() { return decimal.Parse(Next()); } public string[] StringArray() { Next(); Index = S.Length; return S.ToArray(); } public int[] IntArray() { return StringArray().Select(int.Parse).ToArray(); } public long[] LongArray() { return StringArray().Select(long.Parse).ToArray(); } public bool EndOfStream { get { return Sr.EndOfStream; } } } class Magatro { int N; public void Solve() { var cin = new Scanner(Console.OpenStandardInput()); int h = cin.NextInt(); int w = cin.NextInt(); int k = cin.NextInt(); int p = cin.NextInt(); int[] x = new int[k]; int[] y = new int[k]; string[] n = new string[k]; int mod = (int)1e9 + 7; for (int i = 0; i < k; i++) { x[i] = cin.NextInt(); y[i] = cin.NextInt(); n[i] = cin.Next(); } bool[] ans = null; int max = 0; for (int i = 0; i <= 1 << k; i++) { bool[] b = new bool[k]; int cnt = 0; int cpi = i; for(int j = 0; j < k; j++) { if(cpi%2 == 1) { cnt++; b[j] = true; } cpi /= 2; } if (cnt != p) { continue; } int[,] tr = new int[h + 1, w + 1]; for(int j = 0; j < k; j++) { if (!b[j]) { tr[x[j], y[j]] = -1; } } tr[0, 0] = 1; for(int j = 0; j <= h; j++) { for(int l = 0; l <= w; l++) { if (tr[j, l] == -1) continue; if (j + 1 <= h) { if (tr[j + 1, l] != -1) { tr[j + 1, l] += tr[j, l]; tr[j + 1, l] %= mod; } } if (l + 1 <= w) { if (tr[j, l+1] != -1) { tr[j, l+1] += tr[j, l]; tr[j, l+1] %= mod; } } } } if (max < tr[h, w]) { ans = b; max = tr[h, w]; } } Console.WriteLine(max); if(max != 0) { for(int i = 0; i < k; i++) { if (ans[i]) { Console.WriteLine(n[i]); } } } } }