結果

問題 No.82 市松模様
ユーザー r2en_r2en_
提出日時 2017-03-12 18:56:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 480 bytes
コンパイル時間 516 ms
コンパイル使用メモリ 64,472 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 12:06:33
合計ジャッジ時間 1,184 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:12:13: 警告: ‘d’ may be used uninitialized [-Wmaybe-uninitialized]
   12 |             if(d == 'B'){if(j%2==0){cout << "B";}else{cout << "W";}}
      |             ^~
main.cpp:6:12: 備考: ‘d’ はここで定義されています
    6 |     char c,d;
      |            ^

ソースコード

diff #

#include <iostream>
using namespace std;

int main(){
    int w,h;
    char c,d;
    cin >> w >> h >> c;
    for(int i = 0; i < h; ++i){
        if(c=='B'){if(i%2!=0){d = 'W';}else{d='B';}}
        else if(c=='W'){if(i%2!=0){d = 'B';}else{d='W';}}
        for(int j = 0; j < w; ++j){
            if(d == 'B'){if(j%2==0){cout << "B";}else{cout << "W";}}
            else if(d == 'W'){if(j%2==0){cout << "W";}else{cout << "B";}}
        }
        cout << "\n";
    }
    return 0;
}
0