結果
| 問題 | No.3721 Absurd Basic Constructive |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-02 21:23:02 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 33 ms / 2,000 ms |
| + 827µs | |
| コード長 | 1,570 bytes |
| 記録 | |
| コンパイル時間 | 4,301 ms |
| コンパイル使用メモリ | 353,876 KB |
| 実行使用メモリ | 9,924 KB |
| 最終ジャッジ日時 | 2026-10-02 21:23:17 |
| 合計ジャッジ時間 | 9,692 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 47 |
ソースコード
#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,K;cin>>N>>K;
if(K==0)cout<<"-1\n",exit(0);
if(K<N){
rep(i,K-1){
cout<<(i+1)*N<<' ';
rep(j,N-1)cout<<i*N+j+1<<' ';
cout<<'\n';
}cout<<N*N<<' ';
rep(j,N-1)cout<<(N-1)*N+j+1<<' ';
cout<<'\n';
for(ll i=K-1;i<N-1;++i){
rep(j,N)cout<<i*N+j+1<<' ';
cout<<'\n';
}exit(0);
}ll k=K-N;
vector<ll>v(N);
rep(i,N)v[i]=min(k,N-1),k-=v[i];
rep(i,N){
rep(j,v[i])cout<<i*N+j+1<<' ';
cout<<(i+1)*N<<' ';
rep(j,N-v[i]-1)cout<<i*N+v[i]+j+1<<' ';
cout<<'\n';
}
}