結果

問題 No.3721 Absurd Basic Constructive
コンテスト
ユーザー eiram
提出日時 2026-09-19 13:25:34
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.92.0 + ACL)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 54 ms / 2,000 ms
+ 726µs
コード長 1,653 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,344 ms
コンパイル使用メモリ 264,108 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2026-09-19 13:30:56
合計ジャッジ時間 10,497 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

#define INF 1LL<<60
#define MOD 998244353
#define MMOD 1000000007
using mint=modint998244353;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
template<typename T> using vc=vector<T>;
template<typename T> using vv=vc<vc<T>>;
using vl=vector<ll>;
using vvl=vv<ll>;
using vs=vc<string>;
using vvs=vv<string>;
using vb=vc<bool>;
using vvb=vv<bool>;
using lP=pair<ll,ll>;
using vlp=vc<lP>;

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;}

#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define YN {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define all(a) a.begin(),a.end()
#define debug(var) cout << #var << " = " << var << endl;

template<class T> struct Edge {
    ll from;
    ll to;
    T val;
    Edge(ll f, ll t,T v) : from(f), to(t), val(v) { }
};
template<class T> using Graph=vector<vector<Edge<T>>>;

//下、上、右、左の順番
vl dx={0,0,1,-1,1,1,-1,-1};
vl dy={1,-1,0,0,1,-1,1,-1};

//長方形の右下がmaxになるグリッドを考える
//
int main() {
    ll n,k;
    cin>>n>>k;
    
    if(k==0){
        cout<<-1<<endl;
        return 0;
    }
    vvl ans(n,vl(n,0));
    ll now=n*n-k+1;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            if(now==n*n+1) now=1;
            ans[i][j]=now;
            now++;
        }
    }
    
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<"\n";
    }
}
0