結果

問題 No.3721 Absurd Basic Constructive
コンテスト
ユーザー ammonitenh3
提出日時 2026-09-19 13:04:38
言語 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
結果
AC  
実行時間 53 ms / 2,000 ms
+ 79µs
コード長 1,753 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,960 ms
コンパイル使用メモリ 393,032 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2026-09-19 13:08:09
合計ジャッジ時間 11,875 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using mint = modint998244353;
#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;}

const ll inf=1000000000000000000;
const ll mod=998244353;
const double pi=acos(-1);

ll root(ll x){
    ll k=(ll)sqrt(x);
    while(k*k>x) k--;
    while((k+1)*(k+1)<=x) k++;
    return k;
}

//logN
void press(vector<ll> &a){
    map<ll,ll> ord;
    for(auto x:a) ord[x]=1;
    ll j=0;
    for(auto &p:ord){
        p.second=j;
        j++;
    }
    for(auto &x:a) x=ord[x];
    return;
}

mint kaijou(ll n){
    mint a=1;
    rep(i,n){
        a*=(i+1);
    }
    return a;
}

vector<vector<mint>> matmul(vector<vector<mint>> &a,vector<vector<mint>> &b){
    vector<vector<mint>> ret(a.size(),vector<mint>(b[0].size()));
    rep(i,a.size()) rep(j,b[0].size()) rep(k,b.size()) ret[i][j]+=a[i][k]*b[k][j];
    return ret;
}

vector<vector<mint>> matpow(vector<vector<mint>> a,ll n){
    ll siz=a.size();
    vector<vector<mint>> ret(siz,vector<mint>(siz));
    while(n>0){
        if(n&1) ret=matmul(a,ret);
        rep(i,siz) ret[i][i]=1;
        a=matmul(a,a);
        n=n/2;
    }
    return ret;
}

int main () {
    ll n,k;
    cin>>n>>k;
    vector<ll> ans(n*n);
    if(k==0){
        cout<<-1<<endl;
        return 0;
    }
    rep(i,k) ans[i]=n*n+1-k+i;
    rep(i,n*n-k) ans[k+i]=i+1;
    rep(i,n) {
        rep(j,n){
            cout<<ans[i*n+j]<<" ";
        }
        cout<<endl;
    }
}
0