Submission #1112884
Source Code Expand
fn get_one_i32() -> i32 { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().unwrap() } fn get_two_i32() -> (i32, i32) { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let v = s.trim().split(' ').collect::<Vec<_>>(); (v[0].parse().unwrap(), v[1].parse().unwrap()) } fn abc004() { let n = get_one_i32(); let mut lines: Vec<(i32, i32)> = Vec::new(); { fn align_start(st: &i32) -> i32 { // 直前の5分に合わせる *st / 5 * 5 } fn align_end(ed: &i32) -> i32 { // 直後の5分に合わせる if *ed != *ed / 5 * 5 { // 60分を超えたら1時間足す if (*ed / 5 * 5 + 5) % 100 >= 60 { (*ed + 100) / 100 * 100 } else { *ed / 5 * 5 + 5 } } else { *ed } } for _ in 0..n { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let v = s.trim().split('-') .map(|ss| ss.parse::<i32>().unwrap()) .collect::<Vec<_>>(); let st = align_start(&v[0]); let ed = align_end(&v[1]); lines.push((st, ed)); } lines.sort(); } { fn is_overlapped_modified(l: (i32, i32), r: &mut (i32, i32)) -> (bool, bool) { if l.1 >= r.0 && l.0 <= r.1 { // 重なってる if l.0 < r.0 { r.0 = l.0; return (true, true); } if l.1 > r.1 { r.1 = l.1; return (true, true); } return (true, false); } (false, false) } fn add_or_update(l: (i32, i32), rs: &mut Vec<(i32, i32)>) -> () { let mut o = false; let mut m = false; let mut f2 = true; while f2 { if (rs.len() > 0) { for r in rs.iter_mut() { let om = is_overlapped_modified(l, r); o = o || om.0; m = om.1; if !m { f2 = false; } } } else { f2 = false; } } if !o { rs.push(l); } } let mut rs: Vec<(i32, i32)> = Vec::new(); for l in &lines { add_or_update(*l, &mut rs); } for r in &rs { println!("{:>04}-{:>04}", r.0, r.1); } } } fn main() { abc004(); }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | marony |
Language | Rust (1.15.1) |
Score | 100 |
Code Size | 2914 Byte |
Status | AC |
Exec Time | 12 ms |
Memory | 4352 KB |
Compile Error
warning: unnecessary parentheses around `if` condition, #[warn(unused_parens)] on by default --> ./Main.rs:69:20 | 69 | if (rs.len() > 0) { | ^^^^^^^^^^^^^^ warning: function is never used: `get_two_i32`, #[warn(dead_code)] on by default --> ./Main.rs:7:1 | 7 | fn get_two_i32() -> (i32, i32) { | _^ starting here... 8 | | let mut s = String::new(); 9 | | std::io::stdin().read_line(&mut s).ok(); 10 | | let v = s.trim().split(' ').collect::<Vec<_>>(); 11 | | (v[0].parse().unwrap(), v[1].parse().unwrap()) 12 | | } | |_^ ...ending here warning: value assigned to `m` is never read, #[warn(unused_assignments)] on by default --> ./Main.rs:66:17 | 66 | let mut m = false; | ^^^^^
Judge Result
Set Name | all | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
all | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 2 ms | 4352 KB |
00_sample_02.txt | AC | 2 ms | 4352 KB |
00_sample_03.txt | AC | 2 ms | 4352 KB |
cho_cho_chokudai.txt | AC | 9 ms | 4352 KB |
chokudai_ga_cho.txt | AC | 10 ms | 4352 KB |
test_01.txt | AC | 2 ms | 4352 KB |
test_02.txt | AC | 2 ms | 4352 KB |
test_03.txt | AC | 2 ms | 4352 KB |
test_04.txt | AC | 2 ms | 4352 KB |
test_05.txt | AC | 2 ms | 4352 KB |
test_06.txt | AC | 2 ms | 4352 KB |
test_07.txt | AC | 2 ms | 4352 KB |
test_08.txt | AC | 2 ms | 4352 KB |
test_09.txt | AC | 2 ms | 4352 KB |
test_10.txt | AC | 2 ms | 4352 KB |
test_11.txt | AC | 2 ms | 4352 KB |
test_12.txt | AC | 2 ms | 4352 KB |
test_13.txt | AC | 2 ms | 4352 KB |
test_14.txt | AC | 2 ms | 4352 KB |
test_15.txt | AC | 2 ms | 4352 KB |
test_16.txt | AC | 2 ms | 4352 KB |
test_17.txt | AC | 2 ms | 4352 KB |
test_18.txt | AC | 2 ms | 4352 KB |
test_19.txt | AC | 2 ms | 4352 KB |
test_20.txt | AC | 2 ms | 4352 KB |
test_21.txt | AC | 12 ms | 4352 KB |
test_22.txt | AC | 12 ms | 4352 KB |
test_23.txt | AC | 12 ms | 4352 KB |
test_24.txt | AC | 12 ms | 4352 KB |
test_25.txt | AC | 12 ms | 4352 KB |
test_26.txt | AC | 11 ms | 4352 KB |
test_27.txt | AC | 10 ms | 4352 KB |
test_28.txt | AC | 12 ms | 4352 KB |
test_29.txt | AC | 2 ms | 4352 KB |
test_30.txt | AC | 2 ms | 4352 KB |
test_31.txt | AC | 3 ms | 4352 KB |
test_32.txt | AC | 2 ms | 4352 KB |
test_33.txt | AC | 8 ms | 4352 KB |
test_34.txt | AC | 2 ms | 4352 KB |
test_35.txt | AC | 2 ms | 4352 KB |
test_36.txt | AC | 12 ms | 4352 KB |
test_37.txt | AC | 12 ms | 4352 KB |
test_38.txt | AC | 11 ms | 4352 KB |
test_39.txt | AC | 12 ms | 4352 KB |
test_40.txt | AC | 12 ms | 4352 KB |
test_41.txt | AC | 9 ms | 4352 KB |
test_42.txt | AC | 11 ms | 4352 KB |
test_43.txt | AC | 9 ms | 4352 KB |