結果
| 問題 |
No.506 限られたジャパリまん
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-04-21 23:20:34 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,071 bytes |
| コンパイル時間 | 924 ms |
| コンパイル使用メモリ | 117,196 KB |
| 実行使用メモリ | 30,100 KB |
| 最終ジャッジ日時 | 2024-06-28 04:13:12 |
| 合計ジャッジ時間 | 2,682 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 12 |
コンパイルメッセージ
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(tr[h,w] <= 0)
{
continue;
}
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]);
}
}
}
}
}
mban