結果

問題 No.3722 Blended Taste
コンテスト
ユーザー goldenpotato
提出日時 2026-10-03 09:13:34
言語 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,489 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,806 ms
コンパイル使用メモリ 357,212 KB
実行使用メモリ 19,072 KB
最終ジャッジ日時 2026-10-03 09:13:46
合計ジャッジ時間 10,301 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 37 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
#define all(a)a.begin(),a.end()
#define rall(a)a.rbegin(),a.rend()
#define rep(i,n)for(int i=0;i<(n);++i)
#define YN(ans)cout<<(ans?"Yes\n":"No\n")
#define uni(a)sort(all(a)),a.erase(unique(all(a)),a.end())
#define pv(a)cerr<<#a<<':';for(auto e:a)cerr<<' '<<e;cerr<<'\n'
#define pvv(a)cerr<<#a<<':';for(auto e:a){cerr<<'\n';for(auto e2:e)cerr<<' '<<e2;}cerr<<'\n'
#define mine(a)*ranges::min_element(a)
#define maxe(a)*ranges::max_element(a)
#define sume(a)accumulate(all(a),0LL)
template<class T>bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
constexpr int inf=2e9,dx4[4]={0,-1,0,1},dy4[4]={1,0,-1,0},dx8[8]={0,-1,-1,-1,0,1,1,1},dy8[8]={1,1,0,-1,-1,-1,0,1};
constexpr ll INF=2e18;

int main(){
    cin.tie(0)->sync_with_stdio(0),cout<<fixed<<setprecision(0);
    ll N,M,K;cin>>N>>M>>K;
    if(M>K*K)cout<<"-1\n",exit(0);
    vector<ll>cnt(M);
    vector v(K,vector<ll>(K,-1)),ans(N,vector<ll>(N,-1));
    rep(i,K)rep(j,K)if(i*K+j<M)v[i][j]=i*K+j;
    rep(i,N)rep(j,N){
        ll val=v[i%K][j%K];
        ans[i][j]=val;
        if(val!=-1)++cnt[val];
    }rep(i,M)if(cnt[i]>N*N/M)cout<<"-1\n",exit(0);
    rep(i,N)rep(j,N)if(ans[i][j]==-1)rep(k,M)if(cnt[k]+1<=N*N/M){
        ans[i][j]=k,++cnt[k];
        break;
    }rep(i,N){
        rep(j,N)cout<<ans[i][j]+1<<' ';
        cout<<'\n';
    }
}
0