結果

問題 No.3669 误差绝不允许
コンテスト
ユーザー harurun
提出日時 2026-09-03 16:44:25
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,088 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,101 ms
コンパイル使用メモリ 340,660 KB
実行使用メモリ 11,352 KB
最終ジャッジ日時 2026-09-04 23:12:49
合計ジャッジ時間 10,520 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include "testlib.h"
#include <algorithm>
#include <set>
#include <utility>
#include <numeric>
#include <atcoder/dsu>

int main(int argc, char* argv[]){
    registerValidation(argc, argv);

    int N = inf.readInt(2, 30'000);
    inf.readSpace();
    int M = inf.readInt(N - 1, (int)std::min<long long>(50'000, (long long)N * (N - 1) / 2));
    inf.readEoln();
    std::set<std::pair<int, int>> edges;
    atcoder::dsu uf(N);
    for(int j = 0; j < M; j++){
        int u = inf.readInt(1, N);
        inf.readSpace();
        int v = inf.readInt(1, N);
        inf.readSpace();
        ensuref(u != v, "simplicity violation");
        ensuref(edges.find(std::make_pair(std::min(u,v), std::max(u,v))) == edges.end(), "edge duplicates");
        edges.insert({std::min(u,v), std::max(u,v)});
        uf.merge(u - 1, v - 1);
        int a = inf.readInt(1, 300);
        inf.readSpace();
        int b = inf.readInt(1, 300);
        inf.readEoln();
        ensuref(std::gcd(a, b) == 1, "gcd(a, b) violation");
    }
    inf.readEof();
    ensuref(uf.size(0) == N, "connectivity violation");
}
0