結果

問題 No.2121 帰属関係と充足可能性
ユーザー kotatsugamekotatsugame
提出日時 2022-11-04 22:17:31
言語 Ruby
(3.2.2)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 11,372 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2023-09-26 02:57:27
合計ジャッジ時間 6,509 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
14,932 KB
testcase_01 AC 86 ms
15,004 KB
testcase_02 AC 87 ms
15,264 KB
testcase_03 AC 85 ms
15,240 KB
testcase_04 AC 87 ms
15,088 KB
testcase_05 AC 117 ms
15,116 KB
testcase_06 AC 88 ms
14,992 KB
testcase_07 AC 86 ms
14,988 KB
testcase_08 AC 86 ms
15,208 KB
testcase_09 AC 86 ms
15,196 KB
testcase_10 AC 87 ms
15,220 KB
testcase_11 AC 91 ms
15,048 KB
testcase_12 AC 88 ms
15,224 KB
testcase_13 AC 90 ms
15,048 KB
testcase_14 AC 84 ms
15,056 KB
testcase_15 AC 85 ms
15,032 KB
testcase_16 AC 87 ms
15,008 KB
testcase_17 AC 116 ms
15,056 KB
testcase_18 AC 87 ms
15,004 KB
testcase_19 AC 85 ms
14,988 KB
testcase_20 AC 88 ms
15,084 KB
testcase_21 AC 86 ms
15,040 KB
testcase_22 AC 112 ms
15,360 KB
testcase_23 AC 84 ms
15,208 KB
testcase_24 AC 85 ms
15,048 KB
testcase_25 AC 85 ms
14,988 KB
testcase_26 AC 88 ms
15,256 KB
testcase_27 AC 86 ms
15,048 KB
testcase_28 AC 86 ms
15,224 KB
testcase_29 AC 111 ms
15,060 KB
testcase_30 AC 83 ms
15,000 KB
testcase_31 AC 111 ms
15,348 KB
testcase_32 AC 83 ms
15,240 KB
testcase_33 AC 85 ms
15,008 KB
testcase_34 AC 115 ms
15,112 KB
testcase_35 AC 87 ms
15,276 KB
testcase_36 AC 85 ms
15,220 KB
testcase_37 AC 86 ms
15,232 KB
testcase_38 AC 85 ms
15,028 KB
testcase_39 AC 87 ms
15,064 KB
testcase_40 AC 87 ms
14,996 KB
testcase_41 AC 115 ms
15,272 KB
testcase_42 AC 88 ms
15,264 KB
testcase_43 AC 118 ms
15,024 KB
testcase_44 AC 90 ms
15,004 KB
testcase_45 AC 88 ms
15,144 KB
testcase_46 AC 87 ms
14,936 KB
testcase_47 AC 86 ms
14,988 KB
testcase_48 AC 87 ms
15,164 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N=gets.to_i
A=gets.split.map &:to_i
if N==5
  puts A[0]==A[1]&&A[5]!=A[2]&&A[2]!=A[1]&&A[2]!=A[3]&&A[2]!=A[4]&&A[0]!=A[5] ? "YES" : "NO"
  exit
end
v=[]
N.times{
  v=(0...2**v.size).map{|i|
    t=[]
    (0...v.size).each{|j|i[j]==1&&t<<v[j]}
    t
  }
}
sv=v.map &:to_s
puts [*0...v.size].repeated_permutation(3).any?{|m|
  mA0=v[m[A[0]]].map &:to_s
  mA1=v[m[A[1]]].map &:to_s
  mA2=v[m[A[2]]].map &:to_s
  sv.all?{|x|!mA0.include?(x)||mA1.include?(x)}&&
  mA2.include?(sv[m[A[1]]])&&
  mA2.include?(sv[m[A[3]]])&&
  mA2.include?(sv[m[A[4]]])&&
  mA0.include?(sv[m[A[5]]])
} ? "YES" : "NO"
0