結果

問題 No.3722 Blended Taste
コンテスト
ユーザー MM
提出日時 2026-09-19 14:23:39
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,240 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,561 ms
コンパイル使用メモリ 393,436 KB
実行使用メモリ 10,048 KB
最終ジャッジ日時 2026-09-19 14:23:54
合計ジャッジ時間 8,102 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec vector
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back 
#define eb emplace_back

using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
const ll mod = 998244353;
using mint = modint998244353;
const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};
// using Graph = vector<vector<pair<int,ll>>>;
using Graph = vector<vector<int>>;

int divs_nearest(int n, int k){
  assert(n <= 1e9);
  vector<int> d;
  for(int i = 1; i * i <= n; i++){
    if(n % i) continue;
    d.pb(i);
    if(i*i != n) d.pb(n/i);
  }
  sort(all(d));
  auto it = upper_bound(all(d), k);
  --it;
  int res = *it;
  return res;
}

int main(){
  // input
  int N,M,K;
  cin >> N >> M >> K;
  int W = divs_nearest(M,K);
  int H = M / W;
  if(H > K){
    cout << "-1\n";
    return 0;
  }
  
  vec ans(N,vec<int>(N));
  rep(i,N) rep(j,N){
    int x = i % H, y = j % W;
    ans[i][j] = x * H + y + 1;
  }
  
  rep(i,N){
    rep(j,N){
      if(j) cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
}
0