結果

問題 No.1797 永遠のグリッド
ユーザー maple_1016maple_1016
提出日時 2021-12-16 13:21:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 1,481 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 178,576 KB
実行使用メモリ 39,424 KB
最終ジャッジ日時 2024-04-17 12:18:15
合計ジャッジ時間 3,696 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,248 KB
testcase_04 AC 2 ms
5,248 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 5 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 3 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 28 ms
6,400 KB
testcase_18 AC 105 ms
12,288 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 109 ms
14,720 KB
testcase_21 AC 32 ms
8,192 KB
testcase_22 AC 10 ms
5,376 KB
testcase_23 AC 173 ms
23,680 KB
testcase_24 AC 17 ms
6,656 KB
testcase_25 AC 63 ms
13,952 KB
testcase_26 AC 290 ms
39,424 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 33 ms
8,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=2;i*i<=(n);++i)
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sz(x) ((string)(x).size())
#define pb push_back
#define pob pop_back()
#define MMod (ll)1000000007
#define mmod (ll)998244353
#define setp(x) setprecision((ll)(x))
#define INF (ll)(1000000000000000000)
using namespace std;
using vi=vector<int>;
using vc=vector<char>;
using vb=vector<bool>;
using vl=vector<long long>;
using vvi=vector<vi>;
using vvl=vector<vl>;
using vvc=vector<vc>;
using vvb=vector<vb>;
using vpi=vector<pair<int,int>>;
using vpl=vector<pair<ll,ll>>;
using vs=vector<string>;
using pii=pair<int, int>;
using pll=pair<ll,ll>;
using pqi=priority_queue<int>;

int main(){
  int h,w,K; cin>>h>>w>>K;
  int x=h*w,c=0;
  vi q(x,1);
  reps(i,x-1) q[i]*=q[i-1]*K;
  reverse(all(q));
  int kk=1;
  vvi r(h,vi(w)),p(h,vi(w));
  rep(i,x-1) kk*=K;
  map<vvi,int> a;
  rep(i,kk){
    vi aa(K,0);
    int m=i;
    rep(j,x){
      p[j/w][j%w]=m/q[j];
      aa[m/q[j]]=1;
      m%=q[j];
    }
    int d=0;
    rep(j,3) d+=aa[j];
    if(d<K) continue;
    int b=1,bb=1;
    rep(j,h){
      rep(k,w){
        rep(s,h)rep(t,w) r[s][t]=p[(j+s)%h][(k+t)%w];
        if(a[r]==1){
          b=0;
          break;
        }
      }
      if(b==0){
        bb=0;
        break;
      }
    }
    if(bb){ 
      c++;
      a[p]=1;
    }
  }
  cout<<c<<endl;
  return 0;
}
0