結果
問題 |
No.3143 Colorless Green Parentheses Sleep Furiously
|
ユーザー |
|
提出日時 | 2025-05-16 22:21:36 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,353 bytes |
コンパイル時間 | 14,767 ms |
コンパイル使用メモリ | 380,516 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-05-17 00:30:54 |
合計ジャッジ時間 | 20,325 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 WA * 25 |
コンパイルメッセージ
warning: unused variable: `n` --> src/main.rs:41:9 | 41 | n: usize, k: usize, | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default
ソースコード
/* ><> 魚fishに癒されたい ><> >><> ><> ><> ><> ><> ><> >>><>><><<> ><> ><> ><> ><> ><> >><> ^<> ><> >><>> ><> >><><> ><> */ #[allow(unused_imports)] use std::{ convert::{Infallible, TryFrom, TryInto as _}, fmt::{self, Debug, Display, Formatter,}, fs::{File}, hash::{Hash, Hasher}, iter::{Product, Sum}, marker::PhantomData, ops::{Add, AddAssign, Sub, SubAssign, Div, DivAssign, Mul, MulAssign, Neg, RangeBounds}, str::FromStr, sync::{atomic::{self, AtomicU32, AtomicU64}, Once}, collections::{*, btree_set::Range, btree_map::Range as BTreeRange}, mem::{swap}, cmp::{self, Reverse, Ordering, Eq, PartialEq, PartialOrd}, thread::LocalKey, f64::consts::PI, time::Instant, cell::RefCell, io::{self, stdin, Read, read_to_string, BufWriter, BufReader, stdout, Write}, }; #[allow(unused_imports)] use proconio::{input, input_interactive, marker::{*}}; #[allow(unused_imports)] //use rand::{thread_rng, Rng, seq::SliceRandom}; #[allow(unused_imports)] //use ac_library::{*, ModInt998244353 as mint}; #[allow(dead_code)] const INF: i64 = 1<<60; #[allow(dead_code)] const MOD: i64 = 998244353; #[allow(dead_code)] const D: [(usize, usize); 4] = [(1, 0), (0, 1), (!0, 0), (0, !0)]; #[allow(dead_code)] const D2: [(usize, usize); 8] = [(1, 0), (1, 1), (0, 1), (!0, 1), (!0, 0), (!0, !0), (0, !0), (1, !0)]; //use proconio::fastout; //#[fastout] fn main() { input!{ n: usize, k: usize, s: Chars, } let mut cnt = 0; let mut pre = '('; let mut ac = 0; let mut ans = Vec::new(); for (i, &c) in s.iter().enumerate(){ if c=='('{ if cnt==0&&i!=0{ ans.push("+"); } cnt += 1; ans.push("(1+"); } else if cnt==0{ println!("No"); return; } else { cnt -= 1; if pre=='('{ ac += 2; ans.push("1)"); } else { ans.push(")"); ac += 1; } } pre = c; } if cnt==0&&k>=ac{ println!("Yes"); while ac < k{ ans.push("+1"); ac += 1; } println!("{}", ans.join("")); } else { println!("No"); } }