Submission #28302847


Source Code Expand

use proconio::{fastout, input};
use std::iter::repeat;

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    if n % 2 == 1 {
        return;
    }
    let mut s = repeat('(')
        .take(n / 2)
        .chain(repeat(')').take(n / 2))
        .collect::<Vec<_>>();
    loop {
        println!("{}", s.iter().collect::<String>());
        match s.windows(3).rposition(|v| v == &['(', ')', ')']) {
            None => break,
            Some(i) => {
                s.swap(i, i + 1);
                s[i + 1..].sort();
            }
        };
    }
}

Submission Info

Submission Time
Task 002 - Encyclopedia of Parentheses(★3)
User ngtkana
Language Rust (1.42.0)
Score 3
Code Size 588 Byte
Status AC
Exec Time 6 ms
Memory 2184 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 3 / 3
Status
AC × 4
AC × 20
Set Name Test Cases
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 01_sample_04.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 01_sample_04.txt, 02_all_01.txt, 02_all_02.txt, 02_all_03.txt, 02_all_04.txt, 02_all_05.txt, 02_all_06.txt, 02_all_07.txt, 02_all_08.txt, 02_all_09.txt, 02_all_10.txt, 02_all_11.txt, 02_all_12.txt, 02_all_13.txt, 02_all_14.txt, 02_all_15.txt, 02_all_16.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 6 ms 2136 KiB
01_sample_02.txt AC 2 ms 2076 KiB
01_sample_03.txt AC 2 ms 2100 KiB
01_sample_04.txt AC 2 ms 2032 KiB
02_all_01.txt AC 1 ms 2040 KiB
02_all_02.txt AC 1 ms 1976 KiB
02_all_03.txt AC 2 ms 2184 KiB
02_all_04.txt AC 2 ms 2044 KiB
02_all_05.txt AC 1 ms 2064 KiB
02_all_06.txt AC 1 ms 2040 KiB
02_all_07.txt AC 1 ms 2124 KiB
02_all_08.txt AC 1 ms 2040 KiB
02_all_09.txt AC 2 ms 2052 KiB
02_all_10.txt AC 3 ms 1972 KiB
02_all_11.txt AC 2 ms 1948 KiB
02_all_12.txt AC 2 ms 2068 KiB
02_all_13.txt AC 2 ms 2072 KiB
02_all_14.txt AC 2 ms 2168 KiB
02_all_15.txt AC 1 ms 2140 KiB
02_all_16.txt AC 6 ms 2112 KiB