結果

問題 No.3727 Garden Master
コンテスト
ユーザー Tehom
提出日時 2026-11-13 12:13:12
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 316 ms / 2,000 ms
+ 37µs
コード長 2,089 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,880 ms
コンパイル使用メモリ 386,568 KB
実行使用メモリ 334,464 KB
最終ジャッジ日時 2026-11-13 12:13:27
合計ジャッジ時間 10,368 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

template <typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;} return false;}
template <typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;} return false;}


void solve(){
  int n; cin >> n;
  vector<vector<vector<pair<int,int>>>> a(n+1);
  rep(t,1,n+1){
    a[t].resize(t);
    if(t%2){
      rep(i,0,t){
        a[t][i].resize(t);
        rep(j,0,t){
          if(i%2 == 0) a[t][i][j].first=j+1;
          else a[t][i][j].first=t-j;
        }
      }
      rep(j,0,t){
        rep(i,0,t){
          if(j%2 == 0) a[t][i][j].second=i+1;
          else a[t][i][j].second=t-i;
        }
      }
    }
    else{
      rep(i,0,t){
        a[t][i].resize(t);
        rep(j,0,t){
          if(i<t/2 && j<t/2)a[t][i][j]=a[t/2][i%(t/2)][j%(t/2)];
          else if(j<t/2) a[t][i][j]={t+1-a[t/2][t/2-1-i%(t/2)][j%(t/2)].first,t+1-a[t/2][t/2-1-i%(t/2)][j%(t/2)].second};
          else if(i<t/2) a[t][i][j]={t+1-a[t/2][i%(t/2)][t/2-1-j%(t/2)].first,t+1-a[t/2][i%(t/2)][t/2-1-j%(t/2)].second};
          else a[t][i][j]={t+1-a[t/2][t/2-1-j%(t/2)][t/2-1-i%(t/2)].first,t+1-a[t/2][t/2-1-j%(t/2)][t/2-1-i%(t/2)].second};
        }
      }
      rep(i,0,t/2)rep(j,t/2,t){
        if((i+j)%2) a[t][i][j].first-=t/2;
        else a[t][i][j].second-=t/2;
      }
      rep(i,t/2,t)rep(j,0,t/2){
        if((i+j)%2 == 0) a[t][i][j].first-=t/2;
        else a[t][i][j].second-=t/2;
      }
      // rep(i,t/2,t)rep(j,t/2,t){
      //   a[t][i][j].first-=t/2;
      //   a[t][i][j].second-=t/2;
      // }
    }
  }

  rep(i,0,n){
    rep(j,0,n) cout << a[n][i][j].first << " "; cout << "\n";
  }
  rep(i,0,n){
    rep(j,0,n) cout << a[n][i][j].second << " "; cout << "\n";
  }
  
  return;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);


  int T=1;
  // cin >> T;
  rep(_,0,T){
    solve();
  }
}
0