結果
| 問題 | No.3558 Dominoes, Black and White |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-06-19 00:40:50 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,450 bytes |
| 記録 | |
| コンパイル時間 | 3,949 ms |
| コンパイル使用メモリ | 84,640 KB |
| 実行使用メモリ | 199,552 KB |
| 最終ジャッジ日時 | 2026-06-19 00:41:27 |
| 合計ジャッジ時間 | 9,863 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 部分点 | 10 % | AC * 30 |
| 満点 | 90 % | AC * 32 TLE * 1 -- * 56 |
| 合計 | 10 点 |
ソースコード
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 = getXYList3();
System.out.println(count);
}
public static int getXYList2(){
ArrayList<Integer[]> Lary = new ArrayList<Integer[]>();
ArrayList<Integer[]> Rary = new ArrayList<Integer[]>();
Integer[] l,r;
int count = 0;
int startx = 0;
for(int i = 0;i < str.length;i++) {
for(int j = 0;j < str.length;j++) {
if("#".equals(str[i][j])) {
l = new Integer[2];
l[0] = i;
l[1] = j;
Lary.add(l);
}
if(".".equals(str[i][j + str.length])) {
r = new Integer[2];
r[0] = i;
r[1] = j + str.length;
Rary.add(r);
}
if(!Lary.isEmpty() && !Rary.isEmpty()) {
l = Lary.removeFirst();
r = Rary.removeFirst();
count += Math.abs(r[0] - l[0]) + Math.abs(r[1] - l[1]);
}
}
}
return count;
}
public static int getXYList3() {
ArrayList<Integer[]> Lary = new ArrayList<Integer[]>();
ArrayList<Integer[]> Rary = new ArrayList<Integer[]>();
Integer[] l,r;
int count = 0;
for(int i = 0;i < str.length;i++) {
for(int j = 0;j < str.length;j++) {
if("#".equals(str[i][j]) && ".".equals(str[i][j + str.length])) {
count += str.length;
}else if("#".equals(str[i][j])) {
l = new Integer[2];
l[0] = i;
l[1] = j;
Lary.add(l);
}else if(".".equals(str[i][j]) && ".".equals(str[i][j+str.length]) ){
r = new Integer[2];
r[0] = i;
r[1] = j+str.length;
Rary.add(r);
}
if(!Lary.isEmpty() && !Rary.isEmpty()) {
l = Lary.removeFirst();
r = Rary.removeFirst();
count += Math.abs(r[0] - l[0]) + (r[1] - l[1]);
}
}
}
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;
}
}