結果
問題 | No.2819 Binary Binary-Operator |
ユーザー |
|
提出日時 | 2024-07-26 22:32:42 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 1,363 bytes |
コンパイル時間 | 12,911 ms |
コンパイル使用メモリ | 391,920 KB |
実行使用メモリ | 25,604 KB |
平均クエリ数 | 3.00 |
最終ジャッジ日時 | 2024-07-26 22:33:09 |
合計ジャッジ時間 | 18,332 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 64 |
ソースコード
use proconio::input_interactive; fn main() { input_interactive! { x:usize, y:usize, } for n in 3.. { for v in 0..1 << n { let mut ops = [[0; 2]; 2]; let mut possible = [[false; 2]; 2]; for p in 0..1 << 4 { for i in 0..2 { for j in 0..2 { if p & (1 << (2 * i + j)) != 0 { ops[i][j] = 1; } else { ops[i][j] = 0; } } } let t = calc(&ops, v, n); possible[t][ops[x][y]] = true; } if (possible[0][0] ^ possible[0][1]) && (possible[1][0] ^ possible[1][1]) { solve(&possible, n, v); return; } } } } fn solve(possible: &[[bool; 2]; 2], n: usize, v: usize) { println!("{}", n); for i in 0..n { print!("{} ", (v >> i) & 1); } println!(); input_interactive! { t:usize, } if possible[t][0] { println!("0"); } else { println!("1"); } } fn calc(ops: &[[usize; 2]; 2], v: usize, n: usize) -> usize { let mut res = ops[v & 1][(v >> 1) & 1]; for i in 2..n { res = ops[res][(v >> i) & 1]; } res }