結果

問題 No.1797 永遠のグリッド
ユーザー merom686merom686
提出日時 2022-01-01 15:00:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 1,119 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 195,812 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 11:42:49
合計ジャッジ時間 3,217 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 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 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 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 10 ms
5,376 KB
testcase_18 AC 28 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 30 ms
5,376 KB
testcase_21 AC 10 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 35 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 13 ms
5,376 KB
testcase_26 AC 44 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 10 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    int c = 1;
    for (int i = 0; i < h * w; i++) {
        c *= k;
    }
    vector<int> f(c, 0);
    int r = 0;

    for (int u = 0; u < c; u++) {
        int p[10][10], q[3] = {};
        int t = u;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                p[i][j] = t % k; t /= k;
                q[p[i][j]] = 1;
            }
        }
        int s = 0;
        for (int i = 0; i < k; i++) {
            s += q[i];
        }
        if (s != k) continue;

        int g = 0;
        for (int x = 0; x < h; x++) {
            for (int y = 0; y < w; y++) {
                int t = 0, s = 1;
                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        t += p[(i + x) % h][(j + y) % w] * s;
                        s *= k;
                    }
                }
                g |= f[t];
            }
        }
        if (g == 0) f[u] = 1, r++;
    }
    cout << r << endl;

    return 0;
}
0