結果

問題 No.3506 All Distance is Square Number
コンテスト
ユーザー nagasan0210
提出日時 2026-04-18 16:01:00
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,406 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,265 ms
コンパイル使用メモリ 332,360 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-18 16:01:15
合計ジャッジ時間 4,062 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(a); i > (int)(b); i--)
#define ll long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define PQ priority_queue<int, vector<int>, greater<int>>
#define PQ_g priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>>
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
const int d4[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
const int d8[8][2] = {{0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}};
void Yes(bool b) {cout << (b ? "Yes" : "No") << endl;}

int main() {
    int n; cin >> n;
    cout << (2 * n - 3) << endl;
    rep(i, 1, n) {
        cout << i << ' ' << (i + 1) << ' ' << (2 * i - 1) << endl;
    }
    rep(i, 3, n + 1) {
        cout << 2 << ' ' << i << ' ' << (2 * i - 2) << endl;
    }

    rep(i, 1, n + 1) {
        rep(j, i + 1, n + 1) {
            if (i == 1) {
                cout << (j - 1) << ' ';
                rep(k, 1, j) cout << k << ' ';
                cout << endl;
            } else {
                cout << (j - 2) << ' ';
                rrep(k, i, 2) cout << (k - 1) << ' ';
                cout << (n - 2 + i) << ' ';
                rep(k, i + 1, j) cout << k << ' ';
                cout << endl;
            }
        }
    }
}
0