結果

問題 No.792 真理関数をつくろう
ユーザー
提出日時 2024-05-30 15:29:24
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 789 bytes
コンパイル時間 14,397 ms
コンパイル使用メモリ 387,464 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-20 21:10:38
合計ジャッジ時間 16,069 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn main() {
	let mut s = String::new();
	std::io::stdin().read_to_string(&mut s).ok();
	let mut l = s.lines();
	let n = l.next().unwrap().parse::<usize>().unwrap();
	if l.clone().all(|s| s.ends_with('1')) {
		println!("A=⊤");
		return;
	}
	if l.clone().all(|s| s.ends_with('0')) {
		println!("A=⊥");
		return;
	}
	let a: Vec<_> = l
		.flat_map(|s| {
			if s.ends_with('0') {
				None
			} else {
				let q = s
					.split(' ')
					.enumerate()
					.flat_map(|(i, c)| {
						if i == n {
							None
						} else {
							Some(format!(
								"{}P_{}",
								if c == "1" { "" } else { "¬" },
								i + 1
							))
						}
					})
					.collect::<Vec<_>>();
				Some(format!("({})", q.join("∧")))
			}
		})
		.collect();
	println!("A={}", a.join("∨"));
}
0