結果
| 問題 | No.3558 Dominoes, Black and White |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-06-18 23:43:03 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,544 bytes |
| 記録 | |
| コンパイル時間 | 2,709 ms |
| コンパイル使用メモリ | 83,952 KB |
| 実行使用メモリ | 163,352 KB |
| 最終ジャッジ日時 | 2026-06-18 23:43:45 |
| 合計ジャッジ時間 | 9,120 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_1 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 部分点 | 10 % | AC * 30 |
| 満点 | 90 % | AC * 31 TLE * 1 -- * 57 |
| 合計 | 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 = 0;
ArrayList<Integer[]> Llist = getXYList("#");
ArrayList<Integer[]> Rlist = getXYList(".");
while(!Llist.isEmpty()) {
Integer[] l = Llist.removeFirst();
Integer[] r = Rlist.removeFirst();
count += Math.abs(r[0] - l[0]) + Math.abs(r[1] - l[1]);
}
System.out.println(count);
}
public static ArrayList<Integer[]> getXYList(String bw){
ArrayList<Integer[]> ary = new ArrayList<Integer[]>();
Integer[] p;
int startx = 0;
if(".".equals(bw)) {
startx = str.length;
}
for(int i = 0;i < str.length;i++) {
for(int j = startx;j < str.length+startx;j++) {
if(bw.equals(str[i][j])) {
p = new Integer[2];
p[0] = i;
p[1] = j;
ary.add(p);
}
}
}
return ary;
}
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;
}
}