結果

問題 No.1797 永遠のグリッド
ユーザー ksukegamesksukegames
提出日時 2022-08-18 22:41:15
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,305 bytes
コンパイル時間 1,285 ms
コンパイル使用メモリ 141,912 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 06:25:18
合計ジャッジ時間 2,561 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 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 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 10 ms
5,376 KB
testcase_18 AC 31 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 33 ms
5,376 KB
testcase_21 AC 11 ms
5,376 KB
testcase_22 AC 4 ms
5,376 KB
testcase_23 AC 39 ms
5,376 KB
testcase_24 AC 5 ms
5,376 KB
testcase_25 AC 15 ms
5,376 KB
testcase_26 AC 53 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 11 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <utility>
#include <tuple>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cassert>
#include <functional>
#include <numeric>
#include <type_traits>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define coutf(f) cout << fixed << setprecision(f)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
const int inf = 1e9;
const ll INF = 1e18;
const int mod = 998244353;
using Graph = vector<vector<int>>;

int main() {
	ll h, w, k;
	cin >> h >> w >> k;
	int c = 1;
	rep(i, h * w) c *= k;
	vector<int> f(c, 0);
	int r = 0;
	rep(u, c) {
		int p[10][10], q[3] = {};
		int t = u;
		rep(i, h) {
			rep(j, w) {
				p[i][j] = t % k;
				t /= k;
				q[p[i][j]] = 1;
			}
		}
		int s = 0;
		rep(i, k) s += q[i];
		if (s != k) continue;
		int g = 0;
		rep(x, h) rep(y, w) {
			int t = 0, s = 1;
			rep(i, h) rep(j, w) {
				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