結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | tamura-up |
提出日時 | 2023-07-21 12:13:46 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 80 ms / 2,000 ms |
コード長 | 6,064 bytes |
コンパイル時間 | 2,846 ms |
コンパイル使用メモリ | 157,280 KB |
実行使用メモリ | 24,420 KB |
スコア | 93,908 |
平均クエリ数 | 245.80 |
最終ジャッジ日時 | 2023-07-21 12:14:06 |
合計ジャッジ時間 | 14,210 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
24,024 KB |
testcase_01 | AC | 35 ms
23,808 KB |
testcase_02 | AC | 41 ms
23,616 KB |
testcase_03 | AC | 31 ms
23,508 KB |
testcase_04 | AC | 39 ms
23,676 KB |
testcase_05 | AC | 43 ms
23,616 KB |
testcase_06 | AC | 38 ms
24,036 KB |
testcase_07 | AC | 53 ms
24,336 KB |
testcase_08 | AC | 34 ms
23,652 KB |
testcase_09 | AC | 33 ms
23,784 KB |
testcase_10 | AC | 39 ms
23,388 KB |
testcase_11 | AC | 33 ms
24,036 KB |
testcase_12 | AC | 33 ms
24,252 KB |
testcase_13 | AC | 33 ms
23,352 KB |
testcase_14 | AC | 67 ms
23,652 KB |
testcase_15 | AC | 49 ms
24,012 KB |
testcase_16 | AC | 31 ms
24,024 KB |
testcase_17 | AC | 35 ms
23,328 KB |
testcase_18 | AC | 33 ms
24,372 KB |
testcase_19 | AC | 48 ms
24,252 KB |
testcase_20 | AC | 35 ms
23,436 KB |
testcase_21 | AC | 34 ms
24,108 KB |
testcase_22 | AC | 33 ms
24,000 KB |
testcase_23 | AC | 36 ms
23,988 KB |
testcase_24 | AC | 44 ms
23,496 KB |
testcase_25 | AC | 42 ms
23,580 KB |
testcase_26 | AC | 47 ms
23,376 KB |
testcase_27 | AC | 52 ms
23,400 KB |
testcase_28 | AC | 41 ms
23,496 KB |
testcase_29 | AC | 50 ms
23,628 KB |
testcase_30 | AC | 33 ms
24,012 KB |
testcase_31 | AC | 35 ms
24,420 KB |
testcase_32 | AC | 33 ms
23,808 KB |
testcase_33 | AC | 45 ms
24,012 KB |
testcase_34 | AC | 36 ms
23,652 KB |
testcase_35 | AC | 31 ms
23,508 KB |
testcase_36 | AC | 37 ms
24,372 KB |
testcase_37 | AC | 35 ms
24,252 KB |
testcase_38 | AC | 31 ms
23,412 KB |
testcase_39 | AC | 33 ms
23,340 KB |
testcase_40 | AC | 45 ms
23,616 KB |
testcase_41 | AC | 35 ms
24,384 KB |
testcase_42 | AC | 40 ms
23,388 KB |
testcase_43 | AC | 42 ms
23,808 KB |
testcase_44 | AC | 44 ms
23,856 KB |
testcase_45 | AC | 30 ms
23,508 KB |
testcase_46 | AC | 51 ms
24,036 KB |
testcase_47 | AC | 33 ms
23,376 KB |
testcase_48 | AC | 35 ms
23,448 KB |
testcase_49 | AC | 32 ms
23,376 KB |
testcase_50 | AC | 61 ms
24,060 KB |
testcase_51 | AC | 36 ms
23,376 KB |
testcase_52 | AC | 58 ms
24,084 KB |
testcase_53 | AC | 44 ms
23,988 KB |
testcase_54 | AC | 32 ms
24,036 KB |
testcase_55 | AC | 54 ms
24,036 KB |
testcase_56 | AC | 33 ms
23,856 KB |
testcase_57 | AC | 51 ms
23,376 KB |
testcase_58 | AC | 30 ms
23,988 KB |
testcase_59 | AC | 42 ms
23,664 KB |
testcase_60 | AC | 55 ms
24,036 KB |
testcase_61 | AC | 36 ms
24,036 KB |
testcase_62 | AC | 36 ms
24,288 KB |
testcase_63 | AC | 56 ms
24,336 KB |
testcase_64 | AC | 38 ms
23,616 KB |
testcase_65 | AC | 31 ms
24,336 KB |
testcase_66 | AC | 44 ms
23,328 KB |
testcase_67 | AC | 43 ms
24,348 KB |
testcase_68 | AC | 35 ms
23,640 KB |
testcase_69 | AC | 48 ms
23,664 KB |
testcase_70 | AC | 40 ms
24,240 KB |
testcase_71 | AC | 37 ms
23,388 KB |
testcase_72 | AC | 51 ms
24,372 KB |
testcase_73 | AC | 44 ms
23,616 KB |
testcase_74 | AC | 80 ms
24,360 KB |
testcase_75 | AC | 32 ms
23,436 KB |
testcase_76 | AC | 38 ms
24,012 KB |
testcase_77 | AC | 38 ms
23,988 KB |
testcase_78 | AC | 33 ms
23,556 KB |
testcase_79 | AC | 36 ms
24,372 KB |
testcase_80 | AC | 54 ms
24,384 KB |
testcase_81 | AC | 33 ms
23,388 KB |
testcase_82 | AC | 30 ms
24,012 KB |
testcase_83 | AC | 37 ms
23,592 KB |
testcase_84 | AC | 35 ms
24,324 KB |
testcase_85 | AC | 36 ms
23,784 KB |
testcase_86 | AC | 58 ms
24,252 KB |
testcase_87 | AC | 31 ms
23,616 KB |
testcase_88 | AC | 31 ms
23,868 KB |
testcase_89 | AC | 31 ms
24,348 KB |
testcase_90 | AC | 49 ms
23,856 KB |
testcase_91 | AC | 30 ms
23,868 KB |
testcase_92 | AC | 45 ms
23,664 KB |
testcase_93 | AC | 44 ms
23,352 KB |
testcase_94 | AC | 49 ms
23,808 KB |
testcase_95 | AC | 37 ms
23,976 KB |
testcase_96 | AC | 31 ms
24,252 KB |
testcase_97 | AC | 56 ms
23,628 KB |
testcase_98 | AC | 32 ms
24,000 KB |
testcase_99 | AC | 36 ms
23,424 KB |
ソースコード
#![allow(unused_imports)] #![allow(unused_macros)] #![allow(dead_code)] #![allow(non_snake_case)] use std::cmp::min; use std::collections::VecDeque; use std::fs::read; use std::io::Write; use std::time::Instant; const Y: usize = 60; const X: usize = 25; const NEG1: usize = !0; // src: https://yukicoder.me/submissions/892593 // // let x = get!(i32); // 1行の i32 の入力を受け取る // let x = get!(i32;2); // 2行の i32 の入力を受け取る // // tuple // let x = get!(i32,i32,i32); // (i32, i32, i32 )のタプルを受け取る // let x = get!(i32,i32,i32;2); // 2行 (i32, i32, i32 )のタプルを受け取る macro_rules! get { ($t:ty) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().parse::<$t>().unwrap() } }; ($($t:ty),*) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( $(iter.next().unwrap().parse::<$t>().unwrap(),)* ) } }; ($t:ty; $n:expr) => { (0..$n).map(|_| get!($t) ).collect::<Vec<_>>() }; ($($t:ty),*; $n:expr) => { (0..$n).map(|_| get!($($t),*) ).collect::<Vec<_>>() }; ($t:ty ;;) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwrap()) .collect::<Vec<_>>() } }; ($t:ty ;; $n:expr) => { (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>() }; } fn read_input() -> Option<Vec<(u32, u32, usize)>> { let n = get!(i32); if n < 0 { return None; } let mut enemies = vec![]; for _ in 0..n { enemies.push(get!(u32,u32,usize)); } Some(enemies) } #[derive(Clone, Copy, Debug)] struct Enemy { hp: u32, pw: u32, y: usize, } struct EnemyPool { col: Vec<VecDeque<Enemy>>, } impl EnemyPool { fn new() -> EnemyPool { EnemyPool { col: vec![VecDeque::new(); X] } } fn add(&mut self, enemy: &(u32, u32, usize)) { self.col[enemy.2].push_back(Enemy { hp: enemy.0, pw: enemy.1, y: Y - 1 }); } fn step(&mut self) { for i in 0..self.col.len() { if let Some(f) = self.col[i].front() { if f.y == 0 { self.col[i].pop_front(); } } for j in 0..self.col[i].len() { self.col[i][j].y -= 1; } } } fn get_first(&self, x: usize) -> Option<&Enemy> { return self.col[x].front(); } fn attack(&mut self, x: usize, level: u32) -> u32 { let mut res = 0; if self.col[x].len() <= 0 { return 0; } if self.col[x][0].hp <= level { res = self.col[x][0].pw; self.col[x].pop_front(); } else { self.col[x][0].hp -= level; } res } } fn main() { let mut iter = 1; let mut pool = EnemyPool::new(); let mut x = 12; let mut level: u32 = 1; let mut score = 0; while let Some(enemies) = read_input() { eprintln!("iter: {}, x:{}, level:{}, score:{}", iter, x, level, score); pool.step(); for e in enemies { pool.add(&e); } if let Some(e) = pool.get_first(x) { if e.y == 0 { break; } } // 移動 let mut best = (-1.0, 0, x); for di in [!0, 1] { let mut ni = x; 'outer: for step in 0..X / 2 { let i = ni; if iter <= 5 { eprintln!("i:{}", i); } for en in &pool.col[i] { if en.y >= step { let att = level * (en.y - step + 1) as u32; if en.hp <= att { let cnt = (en.hp + level - 1) / level; let score = en.pw as f64 / (step as u32 + cnt) as f64; if best.0 < score { best.0 = score; if iter <= 5 { eprintln!("ck {} {} {}", step, i, di); } best.1 = if step == 0 { 0 } else { di }; best.2 = i; } } else if en.y == step { eprintln!("lim:{}", i); break 'outer; } break; } } ni = ni.wrapping_add(di); ni = if ni == X { 0 } else if ni > X { X - 1 } else { ni }; } } if iter <= 5 { eprintln!("{:?}", best); } { let d: usize = best.1; let mv = match d { 0 => "S", 1 => "R", NEG1 => "L", _ => "S" }; println!("{}", mv); x = x.wrapping_add(d); x = if x == X { 0 } else if x > X { X - 1 } else { x }; } // 攻撃 score += pool.attack(x, level); level = score / 100 + 1; std::io::stdout().flush().unwrap(); if iter >= 1000 { break; } iter += 1; } } pub trait SetMinMax { fn setmin(&mut self, v: Self) -> bool; fn setmax(&mut self, v: Self) -> bool; } impl<T> SetMinMax for T where T: PartialOrd { fn setmin(&mut self, v: T) -> bool { *self > v && { *self = v; true } } fn setmax(&mut self, v: T) -> bool { *self < v && { *self = v; true } } }