結果

問題 No.1169 Row and Column and Diagonal
ユーザー poohbearpoohbear
提出日時 2020-08-14 21:45:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 199,420 KB
実行使用メモリ 6,504 KB
最終ジャッジ日時 2023-07-31 21:52:38
合計ジャッジ時間 3,593 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,456 KB
testcase_07 AC 6 ms
4,704 KB
testcase_08 AC 8 ms
5,192 KB
testcase_09 AC 11 ms
5,388 KB
testcase_10 AC 18 ms
6,220 KB
testcase_11 AC 19 ms
6,292 KB
testcase_12 AC 19 ms
6,320 KB
testcase_13 AC 21 ms
6,504 KB
testcase_14 AC 20 ms
6,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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