結果

問題 No.1797 永遠のグリッド
ユーザー otoshigootoshigo
提出日時 2024-03-30 01:43:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 383 ms / 2,000 ms
コード長 918 bytes
コンパイル時間 2,626 ms
コンパイル使用メモリ 218,376 KB
実行使用メモリ 7,040 KB
最終ジャッジ日時 2024-03-30 01:43:12
合計ジャッジ時間 5,815 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 7 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 41 ms
6,676 KB
testcase_18 AC 145 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 163 ms
6,676 KB
testcase_21 AC 51 ms
6,676 KB
testcase_22 AC 18 ms
6,676 KB
testcase_23 AC 226 ms
6,676 KB
testcase_24 AC 25 ms
6,676 KB
testcase_25 AC 91 ms
6,676 KB
testcase_26 AC 383 ms
7,040 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 51 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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";
}
0