AtCoder Beginner Contest 004

Submission #3729539

Source codeソースコード

#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::mem;
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
#[allow(dead_code)]
fn solve() {
    input!{
        n: usize,
    }
    let index: usize = (n - 1) / 5 % 6;
    let ans = vec![1, 2, 3, 4, 5, 6];
    let (left, right) = ans.split_at(index);
    let mut ans = right.to_vec();
    ans.append(&mut left.to_vec());
    //debug!(ans);
    let remainder = (n - 1) % 5;
    //debug!(ans);
    //debug!(pattern2);
    for i in 0..remainder+1 as usize {
        ans.swap(i, i+1);
    }
    for v in ans {
        print!("{}", v);
    }
    print!("\n");
}

Submission

Task問題 C - 入れ替え
User nameユーザ名 wh317706
Created time投稿日時
Language言語 Rust (1.15.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 3178 Byte
File nameファイル名
Exec time実行時間 3 ms
Memory usageメモリ使用量 8572 KB

Test case

Set

Set name Score得点 / Max score Cases
Subtask1 30 / 30 SubTask1/00_sample_00.txt,SubTask1/00_sample_01.txt,SubTask1/00_sample_02.txt,SubTask1/rand_19.txt,SubTask1/rand_2.txt,SubTask1/rand_25.txt,SubTask1/rand_27.txt,SubTask1/rand_33.txt,SubTask1/rand_35.txt,SubTask1/rand_4.txt,SubTask1/rand_44.txt,SubTask1/rand_48.txt,SubTask1/rand_8.txt
Subtask2 70 / 70 SubTask2/00_sample_03.txt,SubTask2/max_case.txt,SubTask2/rand_120009641.txt,SubTask2/rand_134230520.txt,SubTask2/rand_136939465.txt,SubTask2/rand_200732473.txt,SubTask2/rand_211796835.txt,SubTask2/rand_312330341.txt,SubTask2/rand_377341731.txt,SubTask2/rand_384611280.txt,SubTask2/rand_386098102.txt,SubTask2/rand_399010727.txt,SubTask2/rand_409627453.txt,SubTask2/rand_416537730.txt,SubTask2/rand_425486442.txt,SubTask2/rand_493135174.txt,SubTask2/rand_573105326.txt,SubTask2/rand_62794810.txt,SubTask2/rand_649471654.txt,SubTask2/rand_693017484.txt,SubTask2/rand_729197057.txt,SubTask2/rand_759630883.txt,SubTask2/rand_823752210.txt,SubTask2/rand_830399384.txt,SubTask2/rand_893242387.txt,SubTask2/rand_935005824.txt,SubTask2/rand_989703310.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
SubTask1/00_sample_00.txt AC 3 ms 8572 KB
SubTask1/00_sample_01.txt AC 3 ms 8572 KB
SubTask1/00_sample_02.txt AC 3 ms 8572 KB
SubTask1/rand_19.txt AC 3 ms 8572 KB
SubTask1/rand_2.txt AC 3 ms 8572 KB
SubTask1/rand_25.txt AC 3 ms 8572 KB
SubTask1/rand_27.txt AC 3 ms 8572 KB
SubTask1/rand_33.txt AC 3 ms 8572 KB
SubTask1/rand_35.txt AC 3 ms 8572 KB
SubTask1/rand_4.txt AC 3 ms 8572 KB
SubTask1/rand_44.txt AC 3 ms 8572 KB
SubTask1/rand_48.txt AC 3 ms 8572 KB
SubTask1/rand_8.txt AC 3 ms 8572 KB
SubTask2/00_sample_03.txt AC 3 ms 8572 KB
SubTask2/max_case.txt AC 3 ms 8572 KB
SubTask2/rand_120009641.txt AC 3 ms 8572 KB
SubTask2/rand_134230520.txt AC 3 ms 8572 KB
SubTask2/rand_136939465.txt AC 3 ms 8572 KB
SubTask2/rand_200732473.txt AC 3 ms 8572 KB
SubTask2/rand_211796835.txt AC 3 ms 8572 KB
SubTask2/rand_312330341.txt AC 3 ms 8572 KB
SubTask2/rand_377341731.txt AC 3 ms 8572 KB
SubTask2/rand_384611280.txt AC 3 ms 8572 KB
SubTask2/rand_386098102.txt AC 3 ms 8572 KB
SubTask2/rand_399010727.txt AC 3 ms 8572 KB
SubTask2/rand_409627453.txt AC 3 ms 8572 KB
SubTask2/rand_416537730.txt AC 3 ms 8572 KB
SubTask2/rand_425486442.txt AC 3 ms 8572 KB
SubTask2/rand_493135174.txt AC 3 ms 8572 KB
SubTask2/rand_573105326.txt AC 3 ms 8572 KB
SubTask2/rand_62794810.txt AC 3 ms 8572 KB
SubTask2/rand_649471654.txt AC 3 ms 8572 KB
SubTask2/rand_693017484.txt AC 3 ms 8572 KB
SubTask2/rand_729197057.txt AC 3 ms 8572 KB
SubTask2/rand_759630883.txt AC 3 ms 8572 KB
SubTask2/rand_823752210.txt AC 3 ms 8572 KB
SubTask2/rand_830399384.txt AC 3 ms 8572 KB
SubTask2/rand_893242387.txt AC 3 ms 8572 KB
SubTask2/rand_935005824.txt AC 3 ms 8572 KB
SubTask2/rand_989703310.txt AC 3 ms 8572 KB