結果

問題 No.5025 Forest Fire
コンテスト
ユーザー ks2m
提出日時 2026-10-24 16:01:29
言語 Java
(openjdk 27 + 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  
実行時間 57 ms / 2,000 ms
+ 93µs
コード長 3,392 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,249 ms
コンパイル使用メモリ 100,000 KB
実行使用メモリ 43,728 KB
スコア 148,596,922
最終ジャッジ日時 2026-10-24 16:02:28
合計ジャッジ時間 58,822 ms
ジャッジサーバーID
(参考情報)
judge2_0 / <nil>
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Main {
	static boolean batch = false;
	static boolean readFile = false;
	static boolean outFile = false;
	static int caseNum = 0;

	static int N, K;
	static int[][] d;

	static PrintWriter pw;

	public static void main(String[] args) throws Exception {
		if (batch) {
			readFile = true;
		}
		if (readFile) {
			if (batch) {
				long tl = 2000;
				long tw = tl - 200;
				long total = 0;
				int bidx = 0;
				long best = 0;
				int widx = 0;
				long worst = 1000000000000000000L;
				int re = 0;
				int tle = 0;
				for (int z = 0; z < 100; z++) {
					try {
						long st = System.currentTimeMillis();
						long score = solve(z);
						long time = System.currentTimeMillis() - st;
						if (time > tw) {
							System.out.println(score + "\t" + time + "ms");
							if (time > tl) {
								tle++;
							}
						} else {
							System.out.println(score);
						}
						total += score;
						if (score > best) {
							best = score;
							bidx = z;
						}
						if (score < worst) {
							worst = score;
							widx = z;
						}
					} catch (Exception e) {
						System.out.println(z + ":\t" + e.getMessage());
						re++;
					}
				}
				System.out.println("total: " + total);
				System.out.println("best: " + bidx + ": " + best);
				System.out.println("worst: " + widx + ": " + worst);
				System.out.println("RE: " + re);
				System.out.println("TLE: " + tle);
			} else {
				long score = solve(caseNum);
				System.out.println(score);
			}

		} else {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			init(br);
			br.close();
			solve();
		}
	}

	static long solve(int z) throws Exception {
		StringBuilder sb = new StringBuilder();
		sb.append(z);
		while (sb.length() < 4) {
			sb.insert(0, '0');
		}
		File file = new File("G:\\yuki\\5025\\in\\" + sb.toString() + ".txt");
		BufferedReader br = new BufferedReader(new FileReader(file));
		init(br);
		br.close();
		if (outFile) {
			File file2 = new File("G:\\yuki\\5025\\out\\" + sb.toString() + ".txt");
			pw = new PrintWriter(file2);
		}
		long res = solve();
		if (outFile) {
			pw.close();
		}
		return res;
	}

	static void init(BufferedReader br) throws Exception {
		String[] sa = br.readLine().split(" ");
		N = Integer.parseInt(sa[0]);
		K = Integer.parseInt(sa[1]);

		d = new int[N][N];
		for (int i = 0; i < N; i++) {
			char[] s = br.readLine().toCharArray();
			for (int j = 0; j < N; j++) {
				d[i][j] = s[j] - '0';
			}
		}
	}

	static long solve() {
		int n2 = N / 2;
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			if (d[n2][i] > 0) {
				list.add(toInt(n2, i));
				d[n2][i] = -1;
			}
		}
		for (int i = 0; i < N; i++) {
			if (d[i][n2] > 0) {
				list.add(toInt(i, n2));
				d[i][n2] = -1;
			}
		}

		if (outFile) {
			output(pw, list);
		} else if (!batch) {
			output(new PrintWriter(System.out), list);
		}

		long score = 0;
		return score;
	}

	static int toInt(int x, int y) {
		return x * N + y;
	}

	static void output(PrintWriter pw, List<Integer> list) {
		pw.println(list.size());
		for (int p : list) {
			int x = p / N;
			int y = p % N;
			pw.println(x + " " + y);
		}
		pw.flush();
	}

	static class Ans {
		
	}
}
0