提出 #71663748
ソースコード 拡げる
#if !__INCLUDE_LEVEL__
#include __FILE__
void solve() {
int N;
cin>>N;
vvi dp(N,vi(N));
vvb vis(N,vb(N,false));
dp[0][N/2]=1;
int x=0,y=N/2;
vis[x][y]=true;
rep(_,N*N-1){
if(vis[(x+N-1)%N][(y+1)%N]==false){
dp[(x+N-1)%N][(y+1)%N]=dp[x][y]+1;
vis[(x+N-1)%N][(y+1)%N]=true;
x=(x+N-1)%N;
y=(y+1)%N;
}
else {
vis[(x+1)%N][y]=true;
dp[(x+1)%N][y]=dp[x][y]+1;
x=(x+1)%N;
}
}
rep(i,N){rep(j,N){cout<<dp[i][j]<<spa;}cout<<el;}
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int T=1;
//cin>>T;
while(T--)solve();
}
#else
#include <bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint=modint998244353;
// 関数テンプレート
template<typename T> bool chmax(T &m, const T q) {
if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m,const T q){
if(m>q){m=q;return true;}else return false;
}
template<typename T>
bool grid_inside(const T h, const T w, const T &m, const T &n) {
return (m >= 0 && m < h && n >= 0 && n < w);
}
// ループマクロ
#define rep(i,r) for(int i=0;(r)>i;i++)
#define REP(i,l,r) for(int i=(l);i<(r);i++)
#define rrep(i,N) for(int i=(N)-1;i>=0;i--)
#define RREP(i,r,N) for(int i=(N)-1;i>=r;i--)
// コンテナショートカット
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define el '\n'
#define spa " "
#define pb push_back
// YES/NO 出力
#define Yes cout<<"Yes"<<el
#define No cout<<"No"<<el
#define YES cout<<"YES"<<el
#define NO cout<<"NO"<<el
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
// 型エイリアス
using ll=long long;
using ull=unsigned long long;
using pqgi=priority_queue<int, vector<int>, greater<int>>;
using pqgl=priority_queue<long long, vector<long long>, greater<long long>>;
using pqgpl=priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>>;
using pqgptpl=priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>>;
using pqi=priority_queue<int>;
using pii=pair<int, int>;
using tpi=tuple<int,int,int>;
using tpl=tuple<ll,ll,ll>;
using pll=pair<long long, long long>;
using vs=vector<string>;
using vi=vector<int>;
using vb=vector<bool>;
using vl=vector<long long>;
using vc=vector<char>;
using vvi=vector<vector<int>>;
using vvl=vector<vector<long long>>;
using vvc=vector<vector<char>>;
using vvb=vector<vector<bool>>;
using vvs=vector<vector<string>>;
using vpii=vector<pii>;
using vpll=vector<pll>;
using vvpii=vector<vector<pii>>;
using vvpll=vector<vector<pll>>;
using vtiii=vector<tuple<int, int, int>>;
// 定数
const long long INF=1e18;
const int mod=1e9+7;
//const int mod=998244353;
const int MAX=1e5+10;
const int MIN=-1e9;
const vpii dir={{1,0},{-1,0},{0,1},{0,-1}};
#endif
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
200 / 200 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00_sample_00.txt, 00_sample_01.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_00.txt |
AC |
1 ms |
3556 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3496 KiB |
| 01_test_00.txt |
AC |
1 ms |
3556 KiB |
| 01_test_01.txt |
AC |
1 ms |
3632 KiB |
| 01_test_02.txt |
AC |
1 ms |
3592 KiB |
| 01_test_03.txt |
AC |
1 ms |
3624 KiB |
| 01_test_04.txt |
AC |
1 ms |
3752 KiB |
| 01_test_05.txt |
AC |
1 ms |
3684 KiB |
| 01_test_06.txt |
AC |
1 ms |
3684 KiB |
| 01_test_07.txt |
AC |
1 ms |
3760 KiB |
| 01_test_08.txt |
AC |
1 ms |
3724 KiB |
| 01_test_09.txt |
AC |
1 ms |
3624 KiB |
| 01_test_10.txt |
AC |
1 ms |
3720 KiB |