結果
| 問題 |
No.69 文字を自由に並び替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-24 15:36:05 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 993 bytes |
| コンパイル時間 | 12,907 ms |
| コンパイル使用メモリ | 378,684 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 04:57:05 |
| 合計ジャッジ時間 | 13,904 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
struct Input {
a: String,
b: String,
}
fn read_input(cin_lock: &mut StdinLock) -> Input {
let a = next_token(cin_lock);
let b = next_token(cin_lock);
Input { a, b }
}
fn solve(input: Input) {
let mut sorted_a: Vec<char> = input.a.chars().collect();
sorted_a.sort();
let mut sorted_b: Vec<char> = input.b.chars().collect();
sorted_b.sort();
if sorted_a == sorted_b {
println!("YES");
return;
}
println!("NO");
}
fn next_token<T: FromStr>(cin_lock: &mut StdinLock) -> T {
cin_lock
.by_ref()
.bytes()
.map(|c| c.unwrap() as char)
.skip_while(|c| c.is_whitespace())
.take_while(|c| !c.is_whitespace())
.collect::<String>()
.parse::<T>()
.ok()
.unwrap()
}
fn main() {
let cin = stdin();
let mut cin_lock = cin.lock();
let input = read_input(&mut cin_lock);
solve(input);
}