結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー titiatitia
提出日時 2022-12-09 04:09:32
言語 Rust
(1.77.0)
結果
AC  
実行時間 381 ms / 1,000 ms
コード長 1,392 bytes
コンパイル時間 914 ms
コンパイル使用メモリ 163,172 KB
実行使用メモリ 109,512 KB
最終ジャッジ日時 2024-04-22 19:00:43
合計ジャッジ時間 15,655 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 201 ms
105,252 KB
testcase_01 AC 207 ms
109,184 KB
testcase_02 AC 203 ms
105,248 KB
testcase_03 AC 303 ms
109,260 KB
testcase_04 AC 235 ms
108,592 KB
testcase_05 AC 318 ms
109,340 KB
testcase_06 AC 236 ms
109,048 KB
testcase_07 AC 271 ms
108,444 KB
testcase_08 AC 291 ms
109,244 KB
testcase_09 AC 226 ms
109,364 KB
testcase_10 AC 302 ms
109,340 KB
testcase_11 AC 253 ms
109,468 KB
testcase_12 AC 218 ms
108,892 KB
testcase_13 AC 233 ms
108,404 KB
testcase_14 AC 275 ms
109,176 KB
testcase_15 AC 271 ms
108,436 KB
testcase_16 AC 266 ms
108,980 KB
testcase_17 AC 291 ms
109,336 KB
testcase_18 AC 299 ms
109,512 KB
testcase_19 AC 289 ms
109,344 KB
testcase_20 AC 204 ms
105,920 KB
testcase_21 AC 291 ms
109,464 KB
testcase_22 AC 248 ms
109,384 KB
testcase_23 AC 239 ms
109,088 KB
testcase_24 AC 318 ms
109,464 KB
testcase_25 AC 288 ms
109,340 KB
testcase_26 AC 280 ms
109,344 KB
testcase_27 AC 248 ms
109,508 KB
testcase_28 AC 203 ms
105,248 KB
testcase_29 AC 203 ms
105,376 KB
testcase_30 AC 203 ms
105,548 KB
testcase_31 AC 205 ms
106,628 KB
testcase_32 AC 209 ms
107,648 KB
testcase_33 AC 215 ms
108,540 KB
testcase_34 AC 226 ms
109,052 KB
testcase_35 AC 241 ms
109,296 KB
testcase_36 AC 259 ms
109,416 KB
testcase_37 AC 278 ms
109,336 KB
testcase_38 AC 294 ms
109,344 KB
testcase_39 AC 310 ms
109,340 KB
testcase_40 AC 324 ms
109,340 KB
testcase_41 AC 336 ms
109,340 KB
testcase_42 AC 348 ms
109,336 KB
testcase_43 AC 353 ms
109,388 KB
testcase_44 AC 364 ms
109,340 KB
testcase_45 AC 378 ms
109,340 KB
testcase_46 AC 381 ms
109,340 KB
testcase_47 AC 205 ms
105,248 KB
testcase_48 AC 319 ms
109,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let max_length=524288;
    let mut mt=vec![vec![0;19];max_length];
    let mut tos=vec![Vec::new();20];

    for i in 0..max_length{
        for x in 0..19{
            let mut t=0;
            for y in x+1..19{
                if i & (1<<y) !=0{
                    t+=1;
                }
            }
            mt[i][x]=t%2;
        }
    }

    for i in 0..max_length{
        let mut u=0;
        for j in 0..19{
            if i & (1<<j)!=0{
                u+=1;
            }
        }
        tos[u].push(i);
    }

    for i in 0..20{
        tos[i].reverse();
    }

    let mut dp: Vec<Vec<i64>>=vec![vec![0;max_length];2];
    dp[0][0]=1;

    for i in 0..19{
        let a: Vec<usize> = {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect()
        };

        for j in tos[i].clone(){

            for l in 0..2{
                if dp[l][j]!=0{
                    for k in 1..a.len(){
                        let x=a[k]-1;

                        if j & (1<<x)==0{
                            dp[l^mt[j][x]][j^(1<<x)]+=dp[l][j];
                        }
                    }
                }
            }
        }
    }

    println!("{} {}",dp[0][max_length-1],dp[1][max_length-1]);
}
0