結果

問題 No.1831 Parasol
ユーザー pockynypockyny
提出日時 2022-02-05 00:23:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 67,272 KB
最終ジャッジ日時 2025-01-27 20:16:35
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
int ans[1010][1010];
int main(){
    int i,j,n; cin >> n;
    for(i=0;i<2*n - 1;i++) ans[i][n - 1] = 2*n - 1;
    for(j=0;j<n - 1;j++){
        int l = j + 1,r = 2*n - 1 - l;
        int c = l;
        if(j&1){
            for(i=0;i<2*n - 1;i++){
                if(c>0) ans[i][j] = l, c--;
                else ans[i][j] = r;
            }
        }else{
            for(i=2*n - 2;i>=0;i--){
                if(c>0) ans[i][j] = l, c--;
                else ans[i][j] = r;
            }
        }
    }
    cout << 2*n - 1 << endl;
    for(i=0;i<2*n - 1;i++){
        for(j=0;j<n;j++) cout << ans[i][j] << " ";
        cout << endl;
    }
}
0