結果

問題 No.3506 All Distance is Square Number
コンテスト
ユーザー gojoxd
提出日時 2026-04-18 14:52:41
言語 C
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 663 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 265 ms
コンパイル使用メモリ 35,968 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-18 14:52:48
合計ジャッジ時間 4,265 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

int main() {
    int N;
    scanf("%d", &N);

    int M = 2 * N - 3;
    printf("%d\n", M);

    int edge_id = 1;

    // Chain edges
    for (int i = 1; i < N; i++) {
        printf("%d %d %d\n", i, i + 1, i * i);
    }

    // Extra edges from node 1
    for (int i = 3; i <= N; i++) {
        printf("1 %d %d\n", i, i * (i - 1));
    }

    // Output paths (simple: use direct or via chain)
    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            if (i == 1) {
                printf("1 %d\n", j);
            } else {
                printf("%d %d\n", i, j);
            }
        }
    }

    return 0;
}
0