Submission #32319514
Source Code Expand
Copy
use std::collections::VecDeque;use proconio::{input, marker::Chars};fn main() {input! {n: usize,s: Chars,};let mut rs = vec![];for (i, s_i) in s.iter().copied().enumerate() {if s_i == 'R' {rs.push(i);}}let mut counts = vec![];for i in rs {let mut count_a = 0_usize;for j in 1.. {if i < j {break;
use std::collections::VecDeque; use proconio::{input, marker::Chars}; fn main() { input! { n: usize, s: Chars, }; let mut rs = vec![]; for (i, s_i) in s.iter().copied().enumerate() { if s_i == 'R' { rs.push(i); } } let mut counts = vec![]; for i in rs { let mut count_a = 0_usize; for j in 1.. { if i < j { break; } if s[i - j] == 'A' { count_a += 1; } else { break; } } let mut count_c = 0_usize; for j in 1.. { if i + j >= n { break; } if s[i + j] == 'C' { count_c += 1; } else { break; } } let c = count_a.min(count_c); if c > 0 { counts.push(c); } } let mut deque = VecDeque::new(); for c in counts { if c == 1 { deque.push_front(c); } else { deque.push_back(c); } } let mut count = 0_usize; loop { if count % 2 == 0 { // 奇数回目 if let Some(c) = deque.pop_back() { let c = c - 1; if c == 0 { // do nothing } else if c == 1 { deque.push_front(c); } else { deque.push_back(c); } count += 1; } else { break; } } else { // 偶数回目 if deque.pop_front().is_some() { count += 1; } else { break; } } } let ans = count; println!("{}", ans); }
Submission Info
Submission Time | |
---|---|
Task | B - Shorten ARC |
User | bouzuya |
Language | Rust (1.42.0) |
Score | 400 |
Code Size | 1833 Byte |
Status | AC |
Exec Time | 11 ms |
Memory | 4200 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
All | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt, 02_handmade_07.txt, 02_handmade_08.txt, 02_handmade_09.txt, 02_handmade_10.txt, 02_handmade_11.txt, 02_handmade_12.txt, 02_handmade_13.txt, 02_handmade_14.txt, 02_handmade_15.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 6 ms | 1960 KB |
00_sample_02.txt | AC | 1 ms | 2168 KB |
00_sample_03.txt | AC | 4 ms | 2072 KB |
01_random_01.txt | AC | 11 ms | 3600 KB |
01_random_02.txt | AC | 8 ms | 3584 KB |
01_random_03.txt | AC | 9 ms | 3680 KB |
01_random_04.txt | AC | 8 ms | 3500 KB |
01_random_05.txt | AC | 9 ms | 3668 KB |
01_random_06.txt | AC | 8 ms | 3576 KB |
01_random_07.txt | AC | 7 ms | 3596 KB |
01_random_08.txt | AC | 7 ms | 3528 KB |
01_random_09.txt | AC | 7 ms | 3608 KB |
01_random_10.txt | AC | 7 ms | 3576 KB |
02_handmade_01.txt | AC | 6 ms | 4200 KB |
02_handmade_02.txt | AC | 7 ms | 4180 KB |
02_handmade_03.txt | AC | 10 ms | 3648 KB |
02_handmade_04.txt | AC | 8 ms | 3680 KB |
02_handmade_05.txt | AC | 10 ms | 3656 KB |
02_handmade_06.txt | AC | 7 ms | 3708 KB |
02_handmade_07.txt | AC | 7 ms | 3572 KB |
02_handmade_08.txt | AC | 7 ms | 3632 KB |
02_handmade_09.txt | AC | 7 ms | 3700 KB |
02_handmade_10.txt | AC | 8 ms | 3612 KB |
02_handmade_11.txt | AC | 9 ms | 3620 KB |
02_handmade_12.txt | AC | 9 ms | 3700 KB |
02_handmade_13.txt | AC | 6 ms | 3500 KB |
02_handmade_14.txt | AC | 8 ms | 3404 KB |
02_handmade_15.txt | AC | 7 ms | 3392 KB |