Submission #67343583
Source Code Expand
use itertools::Itertools; #[allow(unused_imports)] use proconio::input; fn rec(l: usize, d: u32, a: &mut Vec<u64>) { if d==0 { return; } let nd = d-1; let next_length = 2usize.pow(nd); rec(l, nd, a); rec(l+next_length, nd, a); let mut is_same = true; let k = l+2usize.pow(d); for i in l..k { if a[i] < a[next_length+i] { break; } else if a[i] > a[next_length+i] { is_same = false; break; } } if !is_same { // 反転 // for i in l..l+next_length { // a.swap(i, k-i-1); // } a[l..l+next_length].reverse(); a[(l+next_length)..k].reverse(); a[l..k].reverse(); } } fn solve() { input! { n: u32, mut a: [u64; 2usize.pow(n)] } rec(0, n, &mut a); println!("{}", a.iter().join(" ")); } fn main() { input!{ t: usize, } for _ in 0..t { solve(); } }
Submission Info
Submission Time | |
---|---|
Task | E - Reverse 2^i |
User | ardRiriy |
Language | Rust (rustc 1.70.0) |
Score | 450 |
Code Size | 1038 Byte |
Status | AC |
Exec Time | 110 ms |
Memory | 8072 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 450 / 450 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt |
All | 00_sample_00.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 1880 KiB |
01_test_00.txt | AC | 1 ms | 1804 KiB |
01_test_01.txt | AC | 1 ms | 1940 KiB |
01_test_02.txt | AC | 52 ms | 2748 KiB |
01_test_03.txt | AC | 5 ms | 2196 KiB |
01_test_04.txt | AC | 21 ms | 3056 KiB |
01_test_05.txt | AC | 21 ms | 2916 KiB |
01_test_06.txt | AC | 17 ms | 3096 KiB |
01_test_07.txt | AC | 16 ms | 3116 KiB |
01_test_08.txt | AC | 16 ms | 4004 KiB |
01_test_09.txt | AC | 18 ms | 4052 KiB |
01_test_10.txt | AC | 17 ms | 4008 KiB |
01_test_11.txt | AC | 21 ms | 8072 KiB |
01_test_12.txt | AC | 19 ms | 5752 KiB |
01_test_13.txt | AC | 17 ms | 4524 KiB |
01_test_14.txt | AC | 110 ms | 3428 KiB |
01_test_15.txt | AC | 14 ms | 7492 KiB |
01_test_16.txt | AC | 17 ms | 7492 KiB |
01_test_17.txt | AC | 17 ms | 7500 KiB |
01_test_18.txt | AC | 14 ms | 7504 KiB |
01_test_19.txt | AC | 18 ms | 7500 KiB |
01_test_20.txt | AC | 18 ms | 7500 KiB |
01_test_21.txt | AC | 18 ms | 7512 KiB |
01_test_22.txt | AC | 18 ms | 7532 KiB |
01_test_23.txt | AC | 17 ms | 7608 KiB |
01_test_24.txt | AC | 17 ms | 7500 KiB |