結果
| 問題 |
No.1797 永遠のグリッド
|
| ユーザー |
Nachia
|
| 提出日時 | 2022-01-01 09:30:00 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,641 bytes |
| コンパイル時間 | 2,286 ms |
| コンパイル使用メモリ | 104,624 KB |
| 最終ジャッジ日時 | 2025-01-27 08:15:34 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 27 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(n); i++)
string get_grid_rotate(int H, int W, string S, int h, int w){
string ans(H*W, ' ');
rep(y,H) rep(x,W){
int nxy = (y + h) % H;
int nxx = (x + w) % W;
ans[nxy * W + nxx] = S[y * W + x];
}
return ans;
}
i64 solve(int H, int W, int K){
int ans = 0;
rep(c,1001001001){
string tmp;
int p = c;
rep(i,H*W){ tmp.push_back('0' + p%K); p /= K; }
if(p != 0 && tmp == string(H*W, '0')) break;
int ok = 1;
rep(y,H) rep(x,W) if(get_grid_rotate(H,W,tmp,y,x) < tmp) ok = 0;
rep(t,K) if(tmp.find('0' + t) == string::npos) ok = 0;
ans += ok;
}
return ans;
}
int main(){
int H,W,K; cin >> H >> W >> K;
cout << "const int answer_table[4][11][11] = {";
rep(k,4){
if(k) cout << ",";
cout << "{";
rep(x,11){
if(x) cout << ",";
cout << "{";
rep(y,11){
if(y) cout << ",";
if(k==0){ cout << 0; continue; }
if(x*y==0){ cout << 0; continue; }
if(10<x*y){ cout << 0; continue; }
cout << solve(y,x,k);
}
cout << "}";
}
cout << "}";
}
cout << "};";
cout << "\n";
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia