結果

問題 No.1169 Row and Column and Diagonal
ユーザー NoviNovi
提出日時 2020-08-16 02:07:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,057 bytes
コンパイル時間 1,625 ms
コンパイル使用メモリ 167,788 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 18:14:07
合計ジャッジ時間 2,606 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 5 ms
6,940 KB
testcase_08 AC 7 ms
6,940 KB
testcase_09 AC 8 ms
6,944 KB
testcase_10 AC 16 ms
6,940 KB
testcase_11 AC 17 ms
6,944 KB
testcase_12 AC 18 ms
6,944 KB
testcase_13 AC 18 ms
6,940 KB
testcase_14 AC 17 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<vector<int>> ans(n,vector<int>(n,0));
    for(int i=1; i<=n; i++){
        ans[i-1][i-1]=i;
        if(i>1){
        for(int j=i-2; j>=0; j--){
            if(abs(j-(i-1))+i<=n) ans[i-1][j]=abs(j-(i-1))+i;
            else ans[i-1][j]=abs(j-(i-1))+i-n;
        }
        }
        for(int j=i; j<=n; j++){
            if(i-abs(j-(i-1))>=1) ans[i-1][j]=i-abs(j-(i-1));
            else ans[i-1][j]=i-abs(j-(i-1))+n;
        }
    } 
    for(int i=0; i<n; i++){
        for(int j=0; j<n-1; j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<ans[i][n-1]<<endl;
    }
    return 0;
}
0