以下の内容はhttps://blog.hamayanhamayan.com/entry/2018/08/05/005331より取得しました。


机の配置 [Kotamanegi Online Judge No.69]

https://kotamanegi.com/Problems/view/index.php?page=69

解法

https://kotamanegi.com/Submission/view/index.php?SubmissionID=1603

実装問題。
机をどう配置すれば最適かという問題もあるが、これは詰めるようにして置いていけばいい。
縦1横iの机を配置していくことを考える。
毎回、FをFFにコピーして作業していこう。

int N, H, W;
string F[10], FF[10];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> H >> W;
    rep(y, 0, H) cin >> F[y];

    rep(i, 1, N + 1) {
        int ans = 0;
        rep(y, 0, H) FF[y] = F[y];
        rep(y, 0, H) rep(x, 0, W - i + 1) {
            int ok = 1;
            rep(xx, x, x + i) if (FF[y][xx] == '#') ok = 0;
            if (ok) {
                ans++;
                rep(xx, x, x + i) FF[y][xx] = '#';
            }
        }
        printf("%d\n", ans);
    }
}        



以上の内容はhttps://blog.hamayanhamayan.com/entry/2018/08/05/005331より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14