結果

問題 No.82 市松模様
コンテスト
ユーザー ちよちゃん
提出日時 2016-06-04 14:50:00
言語 Java
(openjdk 27.0.1.0.3 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 179 ms / 5,000 ms
+ 857µs
コード長 938 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,846 ms
コンパイル使用メモリ 95,820 KB
実行使用メモリ 49,100 KB
最終ジャッジ日時 2026-11-20 20:34:01
合計ジャッジ時間 6,271 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package yukicoder;

import java.util.Scanner;

public class Yuki82 {
	
	public static void main(String[] args) {
 
		Scanner scan = new Scanner(System.in);
		
		int w = scan.nextInt();
		int h = scan.nextInt();
		String c = scan.next();
		
		scan.close();
		
		for (int j = 1; j <= h; j++) {
			for (int i = 1; i <= w; i++) {
				test(c,j,i);
			}
			System.out.print("\n");
		}
	}
	
	private static void test(String str,int j,int i) {
		
		if("B".equals(str)){
			if(j%2 == 0) {
				if (i%2 == 0){
					System.out.print("B");
				} else { 
					System.out.print("W");
				}
			}else {
				if (i%2 != 0){
					System.out.print("B");
				} else { 
					System.out.print("W");
				}			
			}
		} else {
			if(j%2 == 0) {
				if (i%2 == 0){
					System.out.print("W");
				} else { 
					System.out.print("B");
				}
			}else {
				if (i%2 != 0){
					System.out.print("W");
				} else { 
					System.out.print("B");
				}			
			}			
		}
	}
}
0