結果
問題 | No.3120 Lower Nim |
ユーザー |
![]() |
提出日時 | 2025-04-20 12:13:45 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 202 ms / 2,000 ms |
コード長 | 1,918 bytes |
コンパイル時間 | 12,942 ms |
コンパイル使用メモリ | 386,788 KB |
実行使用メモリ | 25,972 KB |
平均クエリ数 | 2685.91 |
最終ジャッジ日時 | 2025-04-20 12:14:08 |
合計ジャッジ時間 | 21,578 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 43 |
ソースコード
#![allow( dead_code, non_snake_case, unused_imports, unused_mut, unused_variables, while_true, unused_assignments, clippy::needless_range_loop, clippy::ptr_arg, clippy::type_complexity, clippy::unnecessary_cast )] use proconio::{ input, marker::{Chars, Usize1 as usize1}, source::line::LineSource, }; use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque}; type Memo = HashMap<usize, HashMap<Option<usize>, i64>>; use std::collections::BTreeSet; use std::io::{BufReader, Write, stdin, stdout}; fn lsb(x: u64) -> u64 { x & (x.wrapping_neg()) } fn main() { let stdin = stdin(); let mut source = LineSource::new(BufReader::new(stdin.lock())); input! { from &mut source, N: usize, mut A: [u64; N], }; let mut c = 0; let mut K = 2; let mut A_xor_sum = A.iter().fold(0, |acc, &x| acc ^ x); macro_rules! read { () => { input! { from &mut source, i: usize1, x: u64, stat: usize, }; if K != x { K = x; c = 0; } A_xor_sum ^= A[i]; A[i] -= x; A_xor_sum ^= A[i]; if stat != 0 { return; } K = lsb(A_xor_sum); }; } if A_xor_sum == 0 { println!("Second"); stdout().flush().unwrap(); read!(); } else { println!("First"); K = lsb(A_xor_sum); } loop { while A[c] < K { c += 1; } println!("{} {}", c + 1, K); A_xor_sum ^= A[c]; A[c] -= K; A_xor_sum ^= A[c]; stdout().flush().unwrap(); input! { from &mut source, stat: usize, } if stat != 0 { return; } read!(); } }