結果
| 問題 | 
                            No.82 市松模様
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-04-13 12:13:32 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 1,173 bytes | 
| コンパイル時間 | 18,915 ms | 
| コンパイル使用メモリ | 378,276 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-15 07:49:36 | 
| 合計ジャッジ時間 | 19,919 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 7 | 
ソースコード
use std::io::stdin;
/// エントリポイント
fn main() {
    let input = read_lines();
    println!("{}", checkered_pattern(input));
}
/// 標準入力から文字列を取得します。
fn read_lines() -> String {
    // 1行目
    let mut str1 = String::new();
    stdin().read_line(&mut str1).unwrap();
    str1
}
/// 市松模様の文字列を返します。
fn checkered_pattern(input: String) -> String {
    let sp = input.trim().split_whitespace().collect::<Vec<&str>>();
    let width = sp[0].parse::<i32>().unwrap();
    let height = sp[1].parse::<i32>().unwrap();
    let mut color = sp[2];
    let mut pattern = String::new();
    for _i in 0..height {
        for _i in 0..width {
            if color == "B" {
                pattern += "B";
                color = "W";
            } else {
                pattern += "W";
                color = "B";
            }
        }
        pattern += "\n";
        // TODO: 幅が偶数の場合は反転
        if width % 2 == 0 {
            if color == "W" {
                color = "B"
            } else {
                color = "W"
            }
        }
    }
    pattern.trim().to_string()
}