結果
| 問題 | No.1797 永遠のグリッド |
| ユーザー |
|
| 提出日時 | 2022-05-31 22:11:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 165 ms / 2,000 ms |
| コード長 | 1,917 bytes |
| コンパイル時間 | 1,838 ms |
| コンパイル使用メモリ | 150,372 KB |
| 最終ジャッジ日時 | 2025-01-29 17:17:44 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <sstream>
#include <utility>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <array>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
return (ull)rng() % B;
}
inline double time() {
return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int h,w,k; cin >> h >> w >> k;
vector<vector<int>> s(h,vector<int>(w));
set<vector<vector<int>>> st;
auto dfs=[&](auto dfs,int i,int j)->void{
if(i == h){
set<int> used;
for(int k=0;k<h;k++){
for(int l=0;l<w;l++){
used.insert(s[k][l]);
}
}
if(used.size() != k)return;
auto t = s;
for(int k=0;k<h;k++){
for(int l=0;l<w;l++){
for(int n=0;n<h;n++){
for(int m=0;m<w;m++){
t[n][m] = s[(k+n)%h][(l+m)%w];
}
}
if(st.find(t) != st.end())return;
}
}
st.insert(s);
return;
}
if(j == w){
dfs(dfs,i+1,0); return;
}
for(int p=0;p<k;p++){
s[i][j] = p;
dfs(dfs,i,j+1);
}
};
dfs(dfs,0,0);
cout << st.size() << endl;
}