結果

問題 No.82 市松模様
コンテスト
ユーザー ちよちゃん
提出日時 2016-06-04 14:50:00
言語 Java
(openjdk 26.0.2.1 + 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  
実行時間 86 ms / 5,000 ms
+ 274µs
コード長 938 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,397 ms
コンパイル使用メモリ 86,552 KB
実行使用メモリ 43,980 KB
最終ジャッジ日時 2026-09-11 22:28:57
合計ジャッジ時間 4,280 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

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