結果

問題 No.3710 Universal Tiles
コンテスト
ユーザー GOTKAKO
提出日時 2026-09-11 21:31:26
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 153 ms / 2,000 ms
+ 112µs
コード長 1,040 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,417 ms
コンパイル使用メモリ 224,772 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-09-11 21:31:39
合計ジャッジ時間 4,043 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,M; cin >> N >> M;
    vector<vector<string>> Ss(N,vector<string>(M));
    for(auto &S : Ss) for(auto &s : S) cin >> s;

    auto rot = [&](vector<string> &S) -> void {
        vector<string> T(M,string(M,'.'));
        for(int i=0; i<M; i++) for(int k=0; k<M; k++) T.at(k).at(M-1-i) = S.at(i).at(k);
        swap(S,T);
    };
    int answer = 1001001001;
    auto check = [&]() -> void {
        vector<vector<bool>> B(M,vector<bool>(M));
        for(int i=0; i<N; i++) for(int x=0; x<M; x++) for(int y=0; y<M; y++) if(Ss.at(i).at(x).at(y) == '#') B.at(x).at(y) = true;
        int now = 0;
        for(int x=0; x<M; x++) for(int y=0; y<M; y++) now += B.at(x).at(y);
        answer = min(answer,now);
    };
    auto dfs = [&](auto dfs,int pos) -> void {
        if(pos == N){check(); return;}
        for(int i=0; i<4; i++) dfs(dfs,pos+1),rot(Ss.at(pos));
    };
    dfs(dfs,0);
    cout << answer << endl;

}
0