結果
問題 |
No.3299 K-th MMA String
|
ユーザー |
👑 |
提出日時 | 2025-10-05 14:22:52 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 77 ms / 2,000 ms |
コード長 | 1,006 bytes |
コンパイル時間 | 13,848 ms |
コンパイル使用メモリ | 397,560 KB |
実行使用メモリ | 13,756 KB |
最終ジャッジ日時 | 2025-10-05 14:23:09 |
合計ジャッジ時間 | 15,978 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
use proconio::input; fn solve() -> String { input! { n: usize, k: usize, } if n <= 17 { solve_small(n, k) } else { format!("{}{}", "A".repeat(n - 17), solve_small(17, k)) } } fn solve_small(n: usize, k: usize) -> String { assert!(n <= 17); let mut mma = Vec::new(); for x in 0..(1 << n) { let mut s = String::new(); for i in 0..n { if (x & (1 << i)) == 0 { s.push('A'); } else { s.push('M'); } } if s.contains("MMA") { mma.push(s); } } mma.sort(); mma[k-1].clone() } fn main() { let ans = solve(); println!("{}", ans); } // fn exp() { // let n = 17; // let mut a = 0; // for x in 0..(1 << n) { // let mut s = String::new(); // for i in 0..n { // if (x & (1 << i)) == 0 { // s.push('0'); // } else { // s.push('1'); // } // } // if s.contains("011") { // // println!("{}", s); // a += 1; // } // } // eprintln!("{}", a); // }