結果

問題 No.1797 永遠のグリッド
ユーザー hiro71687khiro71687k
提出日時 2023-07-21 19:23:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,100 ms / 2,000 ms
コード長 1,847 bytes
コンパイル時間 6,120 ms
コンパイル使用メモリ 276,960 KB
実行使用メモリ 39,588 KB
最終ジャッジ日時 2023-10-21 19:38:33
合計ジャッジ時間 10,726 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 12 ms
4,380 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 96 ms
7,128 KB
testcase_18 AC 470 ms
15,096 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 555 ms
16,848 KB
testcase_21 AC 126 ms
8,264 KB
testcase_22 AC 34 ms
5,536 KB
testcase_23 AC 751 ms
23,844 KB
testcase_24 AC 49 ms
6,808 KB
testcase_25 AC 229 ms
14,220 KB
testcase_26 AC 1,100 ms
39,588 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 126 ms
8,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=1000000007;
ld inf=10000999999999900;
int main(){
    ll h,w,k;
    cin >> h >> w >> k;
    if (k==1)
    {
        cout << 1 << endl;
        return 0;
    }
    vector<ll>thr(30,1);
    for (ll i = 1; i < 20; i++)
    {
        thr[i]=thr[i-1]*k;
    }
    map<vector<vector<ll>>,ll>memo;
    for (ll i = 0; i < thr[h*w]; i++)
    {
        vector<vector<ll>>g(h,vector<ll>(w));
        vector<ll>mm(k,0);
        for (ll j = 0; j < h; j++)
        {
            for (ll k = 0; k < w; k++)
            {
                ll y=j*w+k;
                ll x=(i%thr[y+1])/thr[y];
                g[j][k]=x;
                mm[x]=1;
            }
        }
        bool o=true;
        for (ll j = 0; j < k; j++)
        {
            if (mm[j]==0)
            {
                o=false;
                break;
            }
        }
        if (!o)
        {
            continue;
        }
        bool ok=true;
        for (ll j = 0; j < h; j++)
        {
            for (ll k = 0; k < w; k++)
            {
                vector<vector<ll>>gg(h,vector<ll>(w));
                for (ll l = 0; l < h; l++)
                {
                    for (ll m = 0; m < w; m++)
                    {
                        gg[(j+l)%h][(k+m)%w]=g[l][m];
                    }
                }
                if (memo[gg]!=0)
                {
                    ok=false;
                    break;
                }
            }
            if (!ok)
            {
                break;
            }
            
        }
        if (ok)
        {
            memo[g]=1;
        }
    }
    ll ans=0;
    for(auto v:memo){
        ans+=v.second;
    }
    cout << ans << endl;
}
0