結果

問題 No.3558 Dominoes, Black and White
コンテスト
ユーザー shin
提出日時 2026-06-20 11:31:01
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 675 ms / 2,000 ms
コード長 1,235 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,476 ms
コンパイル使用メモリ 83,728 KB
実行使用メモリ 163,228 KB
最終ジャッジ日時 2026-06-20 11:31:39
合計ジャッジ時間 35,746 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
部分点 10 % AC * 30
満点 90 % AC * 89
合計 100 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class No3558 {
	
	public static String[][] str;
	public static boolean[][] tf;

	public static void main(String[] args) throws IOException{
		
		String[] strings = readStr();
		int n = Integer.parseInt(strings[0]);
		
		str = new String[n][n*2];
		for(int i = 1;i <= n;i++) {
			str[i-1] = strings[i].split(""); 
		}
		int count = getCount(n);

		System.out.println(count);
		

	}
	
	public static int getCount(int n) {
		int countx = 0 , county = 0 , count = 0;
		
		for(int i = 0;i < str.length;i++) {
			for(int j = 0;j < str.length * 2;j++ ) {
				if(".".equals(str[i][j])){
					countx += j+1;
					county++;
				}
			}
			if(i < str.length-1) {
				count += Math.abs(county- (i+1) * str.length);
			}
		}
		
		count += countx - n*n*(n+1)/2;
		return count;
	}
	
	public static String[] readStr() throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> list = new ArrayList<>();

		do {
			list.add(br.readLine());
		}while(br.ready());

		br.close();

		String[] text = new String[list.size()];
		list.toArray(text);

		return text;

	}

}
0