結果

問題 No.3722 Blended Taste
コンテスト
ユーザー 👑 ONPU3
提出日時 2026-10-07 20:51:26
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,107 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,119 ms
コンパイル使用メモリ 347,920 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2026-10-07 20:51:56
合計ジャッジ時間 10,725 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    ll n,m,k;cin>>n>>m>>k;
    vector g(n,vector<ll>(n));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            g[i][j]=(j+(i%2?2:0))%m+1;
        }
    }
    for(int a=0;a<=n-k;a++)
    {
        ll cnt=0;
        map<ll,ll>mp;
        for(int i=0;i<k;i++)
        {
            for(int j=0;j<k;j++)
            {
                if(!mp[g[i+a][j]])cnt++;
                mp[g[i+a][j]]++;
            }
        }
        if(cnt!=m)
        {
            cout<<-1<<endl;
            return 0;
        }
        for(int i=k;i<n;i++)
        {
            for(int j=0;j<k;j++)
            {
                mp[g[j+a][i-k]]--;
                if(!mp[g[j+a][i-k]])cnt--;
                if(!mp[g[j+a][i]])cnt++;
                mp[g[j+a][i]]++;
            }
            if(cnt!=m)
            {
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    for(auto v:g)
    {
        for(auto u:v)cout<<u<<" ";
        cout<<endl;
    }
}
0