結果
問題 |
No.1797 永遠のグリッド
|
ユーザー |
|
提出日時 | 2024-03-30 01:43:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 334 ms / 2,000 ms |
コード長 | 918 bytes |
コンパイル時間 | 2,225 ms |
コンパイル使用メモリ | 210,576 KB |
最終ジャッジ日時 | 2025-02-20 15:48:51 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int H,W,K; cin>>H>>W>>K; set<vector<vector<int>>>se; auto search=[&](auto search,vector<vector<int>>V,int nx,int ny)->void{ if(ny==W){ nx++; ny=0; } if(nx==H){ bool ok=true; set<int>cl; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ cl.insert(V[i][j]); } } if(cl.size()!=K)return; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ vector G(H,vector<int>(W)); for(int k=0;k<H;k++){ for(int l=0;l<W;l++){ G[(k+i)%H][(l+j)%W]=V[k][l]; } } if(se.count(G)){ ok=false; break; } } if(!ok)break; } if(ok)se.insert(V); return; } for(int i=0;i<K;i++){ V[nx][ny]=i; search(search,V,nx,ny+1); } }; vector V(H,vector<int>(W)); search(search,V,0,0); cout<<se.size()<<"\n"; }