結果

問題 No.3657 Gathering Stones
コンテスト
ユーザー InTheBloom
提出日時 2026-08-30 13:44:54
言語 D
(dmd 2.113.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 1 ms / 2,000 ms
+ 320µs
コード長 1,116 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,575 ms
コンパイル使用メモリ 171,860 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-30 13:45:05
合計ジャッジ時間 4,295 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 57
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import std;

void main () {
    int N, M;
    readln.read(N, M);
    auto S = new string[](N);
    foreach (i; 0 .. N) {
        S[i] = readln.chomp;
    }

    auto T = new char[][](N, M);
    foreach (i; 0 .. N) {
        T[i] = S[i].dup;
    }

    foreach (j; 0 .. M) {
        int cnt = 0;
        foreach (i; 0 .. N) {
            if (T[i][j] == '#') {
                cnt++;
            }
        }

        foreach (i; 0 .. cnt) {
            T[i][j] = '#';
        }
        foreach (i; cnt .. N) {
            T[i][j] = '.';
        }
    }

    foreach (i; 0 .. N) {
        int cnt = 0;
        foreach (j; 0 .. M) {
            if (T[i][j] == '#') {
                cnt++;
            }
        }

        foreach (j; 0 .. cnt) {
            T[i][j] = '#';
        }
        foreach (j; cnt .. M) {
            T[i][j] = '.';
        }
    }

    foreach (i; 0 .. N) {
        writeln(T[i]);
    }
}

void read (T...) (string S, ref T args) {
    import std.conv : to;
    import std.array : split;
    auto buf = S.split;
    foreach (i, ref arg; args) {
        arg = buf[i].to!(typeof(arg));
    }
}
0