結果

問題 No.3721 Absurd Basic Constructive
コンテスト
ユーザー Nihonielse
提出日時 2026-09-19 13:13:22
言語 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  
実行時間 51 ms / 2,000 ms
+ 402µs
コード長 2,054 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,244 ms
コンパイル使用メモリ 357,308 KB
実行使用メモリ 10,032 KB
最終ジャッジ日時 2026-09-19 13:25:02
合計ジャッジ時間 9,374 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#line 1 "codes/Libraries/Core.hpp"



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

using ll = long long;
using ull = unsigned long long;

#define rep(i,n) for(int i=0; i<n; i++)
#define rrep(i,n,s) for (int i=s; i<n; i++)


#line 1 "codes/Libraries/Inout.hpp"



#line 5 "codes/Libraries/Inout.hpp"

inline void yn(const bool &tf) {
    if(tf)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

inline void YN(const bool &tf) {
    if(tf)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

inline void Yes() { cout << "Yes" << endl; }
inline void YES() { cout << "YES" << endl; }
inline void No() { cout << "No" << endl; }
inline void NO() { cout << "NO" << endl; }

template <typename T,typename S>
istream& operator>>(istream& is,pair<T,S>& pa){
    is >> pa.first >> pa.second;
    return is;
}

template <typename T,typename S>
ostream& operator<<(ostream& os,pair<T,S>& pa){
    os << pa.first << " " << pa.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is,vector<T>& vec){
    for(T& item:vec){
        is >> item;
    }
    return is;
}

template <typename T>
ostream& operator<<(ostream& os,vector<T>& vec){
    for(int i=0;i<vec.size();i++){
        if(i) os << " ";
        os << vec[i];
    }
    return os;
}
template <typename T>
ostream& operator<<(ostream& os,vector<vector<T>>& vec){
    for(int i=0;i<vec.size();i++){
        os << vec[i];
        if(i<vec.size()-1)os << endl;
    }
    return os;
}

template <typename T,typename S>
ostream& operator<<(ostream& os,vector<pair<T,S>>& vec){
    for(int i=0;i<vec.size();i++){
        os << vec[i];
        if(i<vec.size()-1)os << endl;
    }
    return os;
}


#line 3 "codes/A.cpp"

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

// 左上からそのマスまでで最大ならカウント
0