結果
| 問題 |
No.1169 Row and Column and Diagonal
|
| コンテスト | |
| ユーザー |
poohbear
|
| 提出日時 | 2020-08-14 21:45:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 1,028 bytes |
| コンパイル時間 | 2,126 ms |
| コンパイル使用メモリ | 192,256 KB |
| 最終ジャッジ日時 | 2025-01-12 23:33:55 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
using Graph = vector<vector<ll> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
//input
ll n;
int ans[510][510];
int solve[510][1010];
int main(){
cin >> n;
for(int i=1;i<=n;i++){
solve[i][i]=i;
solve[i][i+n]=i;
for(int j=1;i-j>0;j++){
solve[i][i+j]=i-j;
}
for(int j=1;i+j<=n;j++){
solve[i][i+n-j]=i+j;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
ans[i][j]=max(solve[i][j],solve[i][j+n]);
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<n;j++){
cout << ans[i][j] << ' ';
}
cout << ans[i][n] << endl;
}
return 0;
}
poohbear