Submission #39905020
Source Code Expand
use proconio::input;
fn main() {
input! {
_l: usize,
n_1: usize,
n_2: usize,
vl_1: [(usize, usize); n_1],
vl_2: [(usize, usize); n_2],
};
let (vl_1, vl_2) = {
let mut vl1 = vec![];
let mut count = 0_usize;
for (v_1, l_1) in vl_1 {
vl1.push((v_1, count + l_1));
count += l_1;
}
let mut vl2 = vec![];
let mut count = 0_usize;
for (v_2, l_2) in vl_2 {
vl2.push((v_2, count + l_2));
count += l_2;
}
(vl1, vl2)
};
let (vl_1, vl_2) = {
let mut vl1 = vec![];
let mut vl2 = vec![];
let mut i_1 = 0_usize;
let mut i_2 = 0_usize;
while i_1 < n_1 && i_2 < n_2 {
let (v_1, l_1) = vl_1[i_1];
let (v_2, l_2) = vl_2[i_2];
match l_1.cmp(&l_2) {
std::cmp::Ordering::Less => {
vl1.push((v_1, l_1));
vl2.push((v_2, l_1));
i_1 += 1;
}
std::cmp::Ordering::Equal => {
vl1.push((v_1, l_1));
vl2.push((v_2, l_2));
i_1 += 1;
i_2 += 1;
}
std::cmp::Ordering::Greater => {
vl1.push((v_1, l_2));
vl2.push((v_2, l_2));
i_2 += 1;
}
}
}
if i_1 < n_1 {
vl1.push(vl_1[i_1]);
}
if i_2 < n_2 {
vl2.push(vl_2[i_2]);
}
// println!("{:?}", vl_1);
// println!("{:?}", vl_2);
// println!("{:?}", vl1);
// println!("{:?}", vl2);
(vl1, vl2)
};
let mut count = 0_usize;
let mut prev = 0_usize;
for ((v1, l), (v2, _)) in vl_1.into_iter().zip(vl_2.into_iter()) {
if v1 == v2 {
count += l - prev;
}
prev = l;
}
let ans = count;
println!("{}", ans);
}
Submission Info
| Submission Time |
|
| Task |
E - 2xN Grid |
| User |
bouzuya |
| Language |
Rust (1.42.0) |
| Score |
500 |
| Code Size |
2040 Byte |
| Status |
AC |
| Exec Time |
40 ms |
| Memory |
17928 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
500 / 500 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_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, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 02_max_14.txt, 02_max_15.txt, 02_max_16.txt, 02_max_17.txt, 02_max_18.txt, 02_max_19.txt, 02_max_20.txt, 02_max_21.txt, 02_max_22.txt, 02_max_23.txt, 02_max_24.txt, 02_max_25.txt, 02_max_26.txt, 02_max_27.txt, 02_max_28.txt, 02_max_29.txt, 02_max_30.txt, 03_edge_31.txt, 03_edge_32.txt, 03_edge_33.txt, 03_edge_34.txt, 03_edge_35.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
7 ms |
2148 KiB |
| 00_sample_01.txt |
AC |
1 ms |
2128 KiB |
| 00_sample_02.txt |
AC |
3 ms |
2148 KiB |
| 01_random_03.txt |
AC |
19 ms |
7648 KiB |
| 01_random_04.txt |
AC |
32 ms |
12436 KiB |
| 01_random_05.txt |
AC |
31 ms |
11620 KiB |
| 01_random_06.txt |
AC |
32 ms |
11268 KiB |
| 01_random_07.txt |
AC |
19 ms |
8424 KiB |
| 01_random_08.txt |
AC |
20 ms |
8620 KiB |
| 01_random_09.txt |
AC |
30 ms |
11240 KiB |
| 01_random_10.txt |
AC |
25 ms |
11476 KiB |
| 01_random_11.txt |
AC |
16 ms |
7800 KiB |
| 01_random_12.txt |
AC |
12 ms |
4920 KiB |
| 01_random_13.txt |
AC |
30 ms |
11244 KiB |
| 02_max_14.txt |
AC |
37 ms |
17852 KiB |
| 02_max_15.txt |
AC |
37 ms |
17872 KiB |
| 02_max_16.txt |
AC |
38 ms |
17928 KiB |
| 02_max_17.txt |
AC |
34 ms |
17792 KiB |
| 02_max_18.txt |
AC |
39 ms |
17872 KiB |
| 02_max_19.txt |
AC |
36 ms |
17868 KiB |
| 02_max_20.txt |
AC |
37 ms |
17884 KiB |
| 02_max_21.txt |
AC |
39 ms |
17888 KiB |
| 02_max_22.txt |
AC |
39 ms |
17844 KiB |
| 02_max_23.txt |
AC |
40 ms |
17900 KiB |
| 02_max_24.txt |
AC |
39 ms |
17928 KiB |
| 02_max_25.txt |
AC |
38 ms |
17876 KiB |
| 02_max_26.txt |
AC |
37 ms |
17780 KiB |
| 02_max_27.txt |
AC |
39 ms |
17760 KiB |
| 02_max_28.txt |
AC |
39 ms |
17860 KiB |
| 02_max_29.txt |
AC |
39 ms |
17820 KiB |
| 02_max_30.txt |
AC |
38 ms |
17876 KiB |
| 03_edge_31.txt |
AC |
7 ms |
3176 KiB |
| 03_edge_32.txt |
AC |
4 ms |
2860 KiB |
| 03_edge_33.txt |
AC |
3 ms |
2144 KiB |
| 03_edge_34.txt |
AC |
1 ms |
2060 KiB |
| 03_edge_35.txt |
AC |
36 ms |
17780 KiB |