結果

問題 No.1797 永遠のグリッド
ユーザー erbowlerbowl
提出日時 2022-08-17 21:21:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 1,202 bytes
コンパイル時間 2,594 ms
コンパイル使用メモリ 208,612 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 09:23:31
合計ジャッジ時間 4,863 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 55 ms
5,376 KB
testcase_18 AC 214 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 210 ms
5,376 KB
testcase_21 AC 56 ms
5,376 KB
testcase_22 AC 16 ms
5,376 KB
testcase_23 AC 217 ms
5,376 KB
testcase_24 AC 17 ms
5,376 KB
testcase_25 AC 58 ms
5,376 KB
testcase_26 AC 213 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 56 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll h,w,k;
    std::cin >> h>>w>>k;
    set<string> se;
    ll ans = 0;
    function<void(string)> dfs = [&](string s){
        if(s.size()<h*w){
            for (int i = 0; i < k; i++) {
                dfs(s+(string){(char)(i+'0')});
            }
        }else{
            set<char> uni;
            for (auto e : s) {
                uni.insert(e);
            }
            if(uni.size()!=k)return;
            bool ok = true;
            string tmp = s;
            for (int i = 0; i <= h-1; i++) {
                for (int j = 0; j <= w-1; j++) {
                    for (int ii = 0; ii < h; ii++) {
                        for (int jj = 0; jj < w; jj++) {
                            tmp[(ii+i)%h*w+(jj+j)%w] = s[ii*w+jj];
                        }
                    }
                    if(se.find(tmp)!=se.end())ok=false;
                }
            }
            if(ok){
                // std::cout << s << std::endl;
                se.insert(s);
                ans++;
            }
        }
    };
    dfs("");
    std::cout << ans << std::endl;
}
0