結果

問題 No.1355 AND OR GAME
ユーザー akakimidoriakakimidori
提出日時 2021-01-17 13:32:11
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 2,496 bytes
コンパイル時間 15,488 ms
コンパイル使用メモリ 379,844 KB
実行使用メモリ 554,636 KB
最終ジャッジ日時 2024-05-07 02:10:50
合計ジャッジ時間 84,918 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 204 ms
55,680 KB
testcase_35 TLE -
testcase_36 TLE -
testcase_37 AC 1 ms
6,940 KB
testcase_38 MLE -
testcase_39 AC 745 ms
222,592 KB
testcase_40 AC 932 ms
267,648 KB
testcase_41 MLE -
testcase_42 MLE -
testcase_43 AC 1,438 ms
365,568 KB
testcase_44 AC 314 ms
82,432 KB
testcase_45 TLE -
testcase_46 AC 756 ms
205,568 KB
testcase_47 TLE -
testcase_48 AC 1,380 ms
396,032 KB
testcase_49 MLE -
testcase_50 AC 1 ms
6,944 KB
testcase_51 AC 1,002 ms
278,912 KB
testcase_52 AC 1,807 ms
491,604 KB
testcase_53 AC 1,258 ms
339,184 KB
testcase_54 TLE -
testcase_55 MLE -
testcase_56 MLE -
testcase_57 AC 1,394 ms
385,144 KB
testcase_58 AC 368 ms
106,624 KB
testcase_59 AC 1 ms
6,944 KB
testcase_60 AC 1,367 ms
367,304 KB
testcase_61 AC 1 ms
6,940 KB
testcase_62 AC 1,014 ms
271,872 KB
testcase_63 TLE -
testcase_64 MLE -
testcase_65 AC 17 ms
6,940 KB
testcase_66 AC 649 ms
187,264 KB
testcase_67 AC 639 ms
176,384 KB
testcase_68 AC 697 ms
174,336 KB
testcase_69 AC 2 ms
6,940 KB
testcase_70 AC 828 ms
208,512 KB
testcase_71 TLE -
testcase_72 TLE -
testcase_73 MLE -
testcase_74 MLE -
testcase_75 MLE -
testcase_76 MLE -
testcase_77 MLE -
testcase_78 AC 1 ms
6,940 KB
testcase_79 AC 1 ms
6,944 KB
testcase_80 MLE -
testcase_81 MLE -
testcase_82 MLE -
testcase_83 MLE -
testcase_84 AC 31 ms
21,760 KB
testcase_85 AC 84 ms
50,340 KB
testcase_86 AC 53 ms
32,128 KB
testcase_87 AC 45 ms
28,672 KB
testcase_88 AC 4 ms
6,944 KB
testcase_89 AC 4 ms
6,944 KB
testcase_90 AC 104 ms
63,108 KB
testcase_91 AC 11 ms
8,832 KB
testcase_92 AC 5 ms
6,940 KB
testcase_93 AC 81 ms
54,016 KB
testcase_94 AC 48 ms
32,512 KB
testcase_95 AC 35 ms
23,680 KB
testcase_96 AC 27 ms
18,560 KB
testcase_97 AC 5 ms
6,940 KB
testcase_98 AC 100 ms
66,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// https://yukicoder.me/problems/no/1246
//?
// ---------- begin input macro ----------
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, bytes) => {
        read_value!($iter, String).bytes().collect::<Vec<u8>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// ---------- end input macro ----------

fn run() {
    input! {
        n: usize,
        x: u64,
        y: u64,
        a: [u64; n],
    }
    type Map = std::collections::BTreeMap<u64, (u64, u8)>;
    let mut dp = vec![Map::new(); n + 1];
    dp[0].insert(x, (0, 0));
    for (i, a) in a.iter().enumerate() {
        let mut map = Map::new();
        for (&t, _) in dp[i].iter() {
            map.insert(t & a, (t, 1));
            map.insert(t | a, (t, 2));
            map.insert(*a, (t, 3));
        }
        dp[i + 1] = map;
    }
    if dp[n].get(&y).is_some() {
        let mut ans = vec![];
        let mut pos = n;
        let mut y = y;
        while pos > 0 {
            let &(pre, op) = dp[pos].get(&y).unwrap();
            ans.push(op);
            y = pre;
            pos -= 1;
        }
        ans.reverse();
        for (i, a) in ans.iter().enumerate() {
            if i > 0 {
                print!(" ");
            }
            print!("{}", *a);
        }
        println!();
    } else {
        println!("-1");
    }
}

fn main() {
    run();
}
0