結果
| 問題 | No.3710 Universal Tiles |
| コンテスト | |
| ユーザー |
あいすあうと
|
| 提出日時 | 2026-09-11 22:51:19 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 56 ms / 2,000 ms |
| + 559µs | |
| コード長 | 2,128 bytes |
| 記録 | |
| コンパイル時間 | 4,407 ms |
| コンパイル使用メモリ | 387,716 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-09-11 22:51:36 |
| 合計ジャッジ時間 | 6,872 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using i128=__int128;
using P=pair<ll,ll>;
template<typename T> using vc=vector<T>;
template<typename T> using vv=vc<vc<T>>;
using vl=vc<ll>;
using vvl=vc<vc<ll>>;
using vul=vc<ull>;
using vs=vc<string>;
using vb=vc<bool>;
#define rep(i,s,n) for(ll i=s;i<(n);i++)
#define Rep(i,s,n) for(ll i=n;i>=s;i--)
#define nall(x) x.begin(),x.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define nexp(v) next_permutation(v)
#define prep(v) prev_permutation(v)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define YN {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define M1 cout<<"-1"<<endl
const long long INF=(1LL<<62)-(1LL<<31)-1;
#define endl '\n'
using mint=modint998244353;
using mint7=modint1000000007;
//vl dx={1,-1,0,0};vl dy={0,0,1,-1};
//vl dx={0,0,1,1,1,-1,-1,-1};vl dy={1,-1,0,1,-1,0,1,-1};
bool out_grid(ll i, ll j, ll h, ll w){return (!(0<=i && i<h && 0<=j && j<w));}
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll ceil_div(ll a,ll b){return (a+(b-1))/b;}
ll n,m,ans=INF;
vv<vs> pt;
vl rot;
auto rotate90(const vs& g){
ll h=g.size(),w=g[0].size();
vs res(w,string(h,'.'));
rep(i,0,h)rep(j,0,w)res[j][h-1-i]=g[i][j];
return res;
}
void solve(){
vs v(m,string(m,'.'));
rep(i,0,n){
ll r=rot[i];
auto &now=pt[i][r];
rep(j,0,m){
rep(k,0,m)if(now[j][k]=='#')v[j][k]='#';
}
}
ll cnt=0;
rep(i,0,m)rep(j,0,m)cnt+=(v[i][j]=='#');
chmin(ans,cnt);
}
void dfs(ll id){
if(id==n){
solve();
return;
}
rep(i,0,4){
rot[id]=i;
dfs(id+1);
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
pt.resize(n,vv<string>(4));
rot.resize(n);
rep(i,0,n){
vs s(m);
rep(j,0,m)cin >> s[j];
pt[i][0]=s;
pt[i][1]=rotate90(pt[i][0]);
pt[i][2]=rotate90(pt[i][1]);
pt[i][3]=rotate90(pt[i][2]);
}
dfs(0);
cout << ans << endl;
}
あいすあうと