結果
| 問題 |
No.2925 2-Letter Shiritori
|
| コンテスト | |
| ユーザー |
ぱるま
|
| 提出日時 | 2024-10-12 17:12:07 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 6,201 bytes |
| コンパイル時間 | 10,587 ms |
| コンパイル使用メモリ | 398,892 KB |
| 実行使用メモリ | 25,640 KB |
| 平均クエリ数 | 1.00 |
| 最終ジャッジ日時 | 2024-10-12 17:12:24 |
| 合計ジャッジ時間 | 12,133 ms |
|
ジャッジサーバーID (参考情報) |
judge / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 10 |
コンパイルメッセージ
warning: unused variable: `ss`
--> src/main.rs:88:32
|
88 | input_interactive!{ss: Chars}
| ^^ help: if this is intentional, prefix it with an underscore: `_ss`
|
= note: `#[warn(unused_variables)]` on by default
warning: fields `n` and `ss` are never read
--> src/main.rs:4:5
|
3 | struct Problem {
| ------- fields in this struct
4 | n: usize,
| ^
5 | ss: Vec<char>,
| ^^
|
= note: `Problem` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis
= note: `#[warn(dead_code)]` on by default
warning: associated items `read` and `solve` are never used
--> src/main.rs:9:8
|
8 | impl Problem {
| ------------ associated items in this implementation
9 | fn read() -> Problem {
| ^^^^
...
17 | fn solve(&self) -> Answer {
| ^^^^^
warning: method `print` is never used
--> src/main.rs:76:8
|
75 | impl Answer {
| ----------- method in this implementation
76 | fn print(&self) {
| ^^^^^
ソースコード
//#[derive_readable]
#[derive(Debug, Clone)]
struct Problem {
n: usize,
ss: Vec<char>,
}
impl Problem {
fn read() -> Problem {
input! {
n: usize,
ss: Chars,
}
Problem { n, ss }
}
fn solve(&self) -> Answer {
let n = self.n;
let ss = &self.ss;
// もしかしてACLない?
let m = 998244353;
let mut dp = vec![vec![0; 3]; n];
let left = 0;
let up = 1;
let right = 2;
// 1文字見ておく
match ss[0] {
'L' => {
dp[0][left] = 1;
}
'U' => {
dp[0][up] = 1;
}
'R' => {
dp[0][right] = 1;
}
_ => {
dp[0][left] = 1;
dp[0][up] = 1;
dp[0][right] = 1;
}
}
for i in 1..n {
if ss[i] == 'L' || ss[i] == '.' {
dp[i][left] = (dp[i - 1][left] + dp[i - 1][up]) % m;
}
if ss[i] == 'U' || ss[i] == '.' {
dp[i][up] = (dp[i - 1][left] + dp[i - 1][up] + dp[i - 1][right]) % m;
}
if ss[i] == 'R' || ss[i] == '.' {
dp[i][right] = (dp[i - 1][left] + dp[i - 1][up] + dp[i - 1][right]) % m;
}
}
//dbg!(&dp);
let ans = (dp[n - 1][left] + dp[n - 1][up] + dp[n - 1][right]) % m;
Answer { ans }
}
#[allow(dead_code)]
fn solve_naive(&self) -> Answer {
todo!();
// let ans = 0;
// Answer { ans }
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
struct Answer {
ans: i64,
}
impl Answer {
fn print(&self) {
println!("{}", self.ans);
}
}
fn main() {
input_interactive!{alpha: char}
println_flush!("{}{}", alpha,alpha);
loop{
input_interactive!{t: char}
if t == '!'{
input_interactive!{ss: Chars}
break;
}
input_interactive!{ss: Chars}
println_flush!("? {}{}", ss[1],ss[0]);
}
//Problem::read().solve().print();
}
#[cfg(test)]
mod tests {
#[allow(unused_imports)]
use super::*;
#[allow(unused_imports)]
use rand::{rngs::SmallRng, seq::SliceRandom, *};
#[test]
fn test_problem() {
assert_eq!(1 + 1, 2);
}
#[allow(dead_code)]
#[derive(Debug)]
struct WrongTestCase {
problem: Problem,
main_ans: Answer,
naive_ans: Answer,
}
#[allow(dead_code)]
fn check(p: &Problem) -> Option<WrongTestCase> {
let main_ans = p.solve();
let naive_ans = p.solve_naive();
if main_ans != naive_ans {
Some(WrongTestCase {
problem: p.clone(),
main_ans,
naive_ans,
})
} else {
None
}
}
#[allow(dead_code)]
fn make_random_problem(rng: &mut SmallRng) -> Problem {
todo!()
// let n = rng.gen_range(1..=10);
// let p = Problem { _a: n };
// println!("{:?}", &p);
// p
}
#[allow(unreachable_code)]
#[test]
fn test_with_naive() {
let num_tests = 0;
let max_wrong_case = 10; // この件数間違いが見つかったら打ち切り
let mut rng = SmallRng::seed_from_u64(42);
// let mut rng = SmallRng::from_entropy();
let mut wrong_cases: Vec<WrongTestCase> = vec![];
for _ in 0..num_tests {
let p = make_random_problem(&mut rng);
let result = check(&p);
if let Some(wrong_test_case) = result {
wrong_cases.push(wrong_test_case);
}
if wrong_cases.len() >= max_wrong_case {
break;
}
}
if !wrong_cases.is_empty() {
for t in &wrong_cases {
println!("{:?}", t.problem);
println!("main ans : {:?}", t.main_ans);
println!("naive ans: {:?}", t.naive_ans);
println!();
}
println!("{} cases are wrong.", wrong_cases.len());
panic!();
}
}
}
use proconio::input_interactive;
// ====== import ======
#[allow(unused_imports)]
use proconio::{
derive_readable, fastout, input,
marker::{Bytes, Chars, Usize1},
};
#[allow(unused_imports)]
use std::cmp::Reverse;
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
// ====== output func ======
#[allow(unused_imports)]
use print_vec::*;
pub mod print_vec {
use proconio::fastout;
#[fastout]
pub fn print_vec<T: std::fmt::Debug>(arr: &[T]) {
for a in arr {
println!("{:?}", a);
}
}
#[fastout]
pub fn print_vec_1line<T: std::fmt::Debug>(arr: &[T]) {
let msg = arr
.iter()
.map(|x| format!("{:?}", x))
.collect::<Vec<String>>()
.join(" ");
println!("{}", msg);
}
#[fastout]
pub fn print_vec2<T: std::fmt::Debug>(arr: &Vec<Vec<T>>) {
for row in arr {
let msg = row
.iter()
.map(|x| format!("{:?}", x))
.collect::<Vec<String>>()
.join(" ");
println!("{}", msg);
}
}
pub fn print_bytes(bytes: &[u8]) {
let msg = String::from_utf8(bytes.to_vec()).unwrap();
println!("{}", msg);
}
pub fn print_chars(chars: &[char]) {
let msg = chars.iter().collect::<String>();
println!("{}", msg);
}
#[fastout]
pub fn print_vec_bytes(vec_bytes: &[Vec<u8>]) {
for row in vec_bytes {
let msg = String::from_utf8(row.to_vec()).unwrap();
println!("{}", msg);
}
}
}
#[allow(unused)]
fn print_yesno(ans: bool) {
let msg = if ans { "Yes" } else { "No" };
println!("{}", msg);
}
// ====== snippet ======
use std::io::{stdout, Write};
#[macro_export]
macro_rules! println_flush {
() => {
println!();
stdout().flush().unwrap();
};
($($arg:tt)*) => {{
println!($($arg)*);
stdout().flush().unwrap();
}};
}
ぱるま