#include #include #include "testlib.h" using namespace std; using namespace atcoder; const int Nmin = 1, Nmax = 100'000; const int Kmin = 1, Kmax = 100'000; const long long Cmin = 1, Cmax = 10'000'000'000; const int Wmin = 0, Wmax = 100'000; const int Pmin = 1, Pmax = 100'000; int main(){ // validation を始める際に必ず行う registerValidation(); int N = inf.readInt(Nmin, Nmax); inf.readSpace(); int K = inf.readInt(Kmin, Kmax); inf.readSpace(); inf.readLong(Cmin, Cmax); inf.readEoln(); set> Edges; dsu uf(N); for(int i = 0; i < K; i++) { int U = inf.readInt(1, N); inf.readSpace(); int V = inf.readInt(1, N); inf.readSpace(); int W = inf.readInt(Wmin, Wmax); inf.readSpace(); int P = inf.readInt(Pmin, Pmax); inf.readEoln(); assert(U != V); if(U > V) swap(U, V); assert(Edges.find(pair(U, V)) == Edges.end()); Edges.insert(pair(U, V)); uf.merge(U - 1, V - 1); } assert(uf.groups().size() == 1); inf.readEof(); return 0; }