結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー | 14番 |
提出日時 | 2016-12-13 03:51:25 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,509 bytes |
コンパイル時間 | 992 ms |
コンパイル使用メモリ | 108,672 KB |
実行使用メモリ | 22,912 KB |
最終ジャッジ日時 | 2024-11-30 00:31:49 |
合計ジャッジ時間 | 5,931 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
19,456 KB |
testcase_01 | AC | 35 ms
19,456 KB |
testcase_02 | RE | - |
testcase_03 | AC | 47 ms
22,912 KB |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | WA | - |
testcase_07 | RE | - |
testcase_08 | AC | 28 ms
18,944 KB |
testcase_09 | AC | 36 ms
19,584 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | WA | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | WA | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | AC | 35 ms
19,456 KB |
testcase_29 | RE | - |
testcase_30 | WA | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | WA | - |
testcase_34 | RE | - |
testcase_35 | WA | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | WA | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | WA | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | AC | 35 ms
19,584 KB |
testcase_54 | AC | 35 ms
19,584 KB |
testcase_55 | AC | 35 ms
19,328 KB |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | RE | - |
testcase_60 | RE | - |
testcase_61 | AC | 35 ms
19,584 KB |
testcase_62 | WA | - |
testcase_63 | RE | - |
testcase_64 | AC | 36 ms
19,456 KB |
testcase_65 | AC | 35 ms
19,584 KB |
testcase_66 | RE | - |
testcase_67 | RE | - |
testcase_68 | RE | - |
testcase_69 | RE | - |
testcase_70 | RE | - |
testcase_71 | RE | - |
testcase_72 | RE | - |
testcase_73 | RE | - |
testcase_74 | RE | - |
testcase_75 | RE | - |
testcase_76 | RE | - |
testcase_77 | RE | - |
testcase_78 | RE | - |
testcase_79 | AC | 27 ms
19,072 KB |
testcase_80 | AC | 26 ms
18,944 KB |
testcase_81 | AC | 27 ms
18,816 KB |
testcase_82 | AC | 27 ms
18,944 KB |
testcase_83 | AC | 26 ms
18,944 KB |
testcase_84 | WA | - |
testcase_85 | AC | 35 ms
19,328 KB |
testcase_86 | AC | 27 ms
18,944 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.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray(); this.Length = inpt[0]; if(inpt[1] == 0) { long ans = 1; for(int i=2; i<=this.Length; i++) { ans*=i; ans = ans % MOD; } Console.WriteLine(ans); } else { this.NumList = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).OrderBy(a=>a).ToArray(); long ans = this.GetAns(0,0); Console.WriteLine(ans); } } private Dictionary<long, long> dic = new Dictionary<long, long>(); private long GetAns(long selected, long flags) { if(dic.ContainsKey(selected)) { return dic[selected]; } long flags2 = flags; for(int i=0; i<this.NumList.Length; i++) { long key = (long)1<<i; if((flags2&key) == key) { continue; } if(selected == this.NumList[i]) { flags2+=key; continue; } if(selected > this.NumList[i]) { dic[selected] = 0; return 0; } long selectedR = long.Parse(string.Join("",Convert.ToString(selected, 2).Select(a=>a=='1'?'0':'1'))); long numR = long.Parse(string.Join("",Convert.ToString(NumList[i], 2).Select(a=>a=='1'?'0':'1'))); if(selected > 0 && (selectedR&numR) != numR) { dic[selected] = 0; return 0; } } if(selected == ((long)1<<this.Length)-1) { if(flags2 == ((long)1<<this.NumList.Length)-1) { dic[selected] = 1; } else { dic[selected] = 0; } return dic[selected]; } if(flags2 == ((long)1<<this.NumList.Length)-1) { int cnt = 0; for(int i=0; i<this.Length; i++) { long key = (long)1<<i; if((selected&key)==0) { cnt++; } } long ret = 1; for(int i=1; i<=cnt; i++) { ret*=i; ret = ret % MOD; } dic[selected] = ret; return ret; } long ans = 0; for(int i=0; i<this.Length; i++) { long key = (long)1<<i; if((selected&key)>0) { continue; } ans+=this.GetAns(selected+key, flags2); ans = ans % MOD; } this.dic[selected] = ans; return ans; } private const long MOD = 1000000000 + 7; private int Length = 0; private long[] NumList; public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" 60 1 8 "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }