Submission #72044449
Source Code Expand
use proconio::input;
fn is_avr(a: &[usize]) -> bool {
return (a[0] == a[1]) && (a[2] == a[3]) && (a[1] == a[3]);
}
// fn dfs(a: Vec<usize>, min: usize) -> usize {
// let mut mini = min;
// // eprintln!("{mini},{a:?}");
// if a.len() < 4 {
// return mini;
// }
// for i in 0..a.len() - 3 {
// if is_avr(&a[i..=i + 3]) {
// let mut aa = a.clone();
// let removed: Vec<_> = aa.drain(i..=i + 3).collect();
// // eprintln!("remove {removed:?}");
// mini = mini.min(dfs(aa, mini - 4));
// return mini;//貪欲で行ける
// }
// }
// return mini;
// }
// fn donyoku(a: &mut Vec<usize>) -> usize {
// // eprintln!("{a:?}");
// if a.len() < 4 {
// return a.len();
// }
// for i in 0..a.len() - 3 {
// if is_avr(&a[i..=i + 3]) {
// let _ = a.drain(i..=i + 3);
// break;
// }
// }
// // donyoku(a);
// return a.len();
// }
// fn main() {
// input! {
// n:usize,
// mut a:[usize;n],
// }
// let mut mini = a.len();
// loop {
// let don_mini = donyoku(&mut a);
// if don_mini == mini {
// break;
// } else {
// mini = don_mini;
// }
// }
// println!("{}", mini)
// }
// //01234 len=5 0 1
fn main() {
input! {
n:usize,
mut a:[usize;n],
}
let mut i = 0;
let mut a_len = a.len();
while i < a_len.saturating_sub(4) {
if is_avr(&a[i..i + 4]) {
let _ = a.drain(i..i + 4);
a_len -= 4;
// println!("{a:?},{a_len},{},{i}", a.len());
if i > 4 {
i -= 4
} else {
i = 0
}
// println!("{a:?},{a_len},{},{i}", a.len());
continue;
}
i += 1;
}
// for i in 0..a.len().saturating_sub(4){
// if
// }
println!("{}", a_len)
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - 1D puyopuyo |
| User | moamoa |
| Language | Rust (rustc 1.89.0) |
| Score | 0 |
| Code Size | 1993 Byte |
| Status | WA |
| Exec Time | > 2000 ms |
| Memory | 5000 KiB |
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 300 | ||||||||
| 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_00.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, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 2060 KiB |
| 00_sample_01.txt | AC | 0 ms | 1864 KiB |
| 00_sample_02.txt | AC | 0 ms | 2024 KiB |
| 01_random_00.txt | WA | 0 ms | 1820 KiB |
| 01_random_01.txt | TLE | > 2000 ms | 4912 KiB |
| 01_random_02.txt | TLE | > 2000 ms | 4924 KiB |
| 01_random_03.txt | TLE | > 2000 ms | 4780 KiB |
| 01_random_04.txt | TLE | > 2000 ms | 4920 KiB |
| 01_random_05.txt | TLE | > 2000 ms | 4808 KiB |
| 01_random_06.txt | TLE | > 2000 ms | 4892 KiB |
| 01_random_07.txt | TLE | > 2000 ms | 4836 KiB |
| 01_random_08.txt | TLE | > 2000 ms | 5000 KiB |
| 01_random_09.txt | TLE | > 2000 ms | 4860 KiB |
| 01_random_10.txt | TLE | > 2000 ms | 4900 KiB |
| 01_random_11.txt | TLE | > 2000 ms | 4724 KiB |
| 01_random_12.txt | TLE | > 2000 ms | 4840 KiB |
| 01_random_13.txt | TLE | > 2000 ms | 4872 KiB |
| 01_random_14.txt | TLE | > 2000 ms | 4768 KiB |
| 01_random_15.txt | TLE | > 2000 ms | 4892 KiB |
| 01_random_16.txt | AC | 6 ms | 4936 KiB |
| 01_random_17.txt | TLE | > 2000 ms | 4864 KiB |