結果

問題 No.5002 stick xor
ユーザー nebukuro09nebukuro09
提出日時 2018-05-26 07:39:42
言語 D
(dmd 2.107.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,500 bytes
コンパイル時間 2,075 ms
実行使用メモリ 8,916 KB
スコア 0
最終ジャッジ日時 2023-06-01 00:00:00
ジャッジサーバーID
(参考情報)
judge7 /
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;

immutable int N = 60;
immutable int K = 500;

void main() {
    readln.split;
    auto L = readln.split.map!(to!int).array;
    auto A = N.iota.map!(_ => readln.chomp.map!(a => a == '1').array).array;
    int[][] ops;

    foreach (l; L) {
        int best_score = -100;
        int[] best_op = [-1, -1, -1, -1];

        foreach (i; 0..N) {
            foreach (j; 0..N-l+1) {
                int score = 0;
                foreach (k; j..j+l) {
                    score += A[i][k] ? 1 : -1;
                }
                if (score > best_score) {
                    best_score = score;
                    best_op = [i, j, i, j+l-1];
                }
            }
        }

        foreach (j; 0..N) {
            foreach (i; 0..N-l+1) {
                int score = 0;
                foreach (k; i..i+l) {
                    score += A[k][j] ? 1 : -1;
                }
                if (score > best_score) {
                    best_score = score;
                    best_op = [i, j, i+l-1, j];
                }
            }
        }

        foreach (i; best_op[0]..best_op[2]+1)
            foreach (j; best_op[1]..best_op[3]+1)
                A[i][j] ^= 1;

        ops ~= best_op;
    }

    foreach (op; ops)
        op.map!(a => (a+1).to!string).join(" ").writeln;
}
0