結果

問題 No.1797 永遠のグリッド
ユーザー ksukegames
提出日時 2022-08-18 22:41:15
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,305 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 142,936 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-06 19:44:39
合計ジャッジ時間 2,807 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

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