Pagini recente » Cod sursa (job #175793) | Cod sursa (job #1164082) | Cod sursa (job #1645627) | Cod sursa (job #2157468) | Cod sursa (job #2652548)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lazy.in");
ofstream fout("lazy.out");
struct Muchie {
int a, b, poz;
long long c1, c2;
bool operator< (const Muchie &m) {
if (c1 != m.c1)
return c1 < m.c1;
else
return c2 > m.c2;
}
};
Muchie aux;
vector<Muchie> muchii;
vector<int> sol;
int n, m, T[200005], p;
int rad(int x) {
while (T[x] > 0)
x = T[x];
return x;
}
int main() {
fin >> n >> m;
for (int i=1;i<=n;++i)
T[i] = -1;
while (fin >> aux.a >> aux.b >> aux.c1 >> aux.c2) {
p++;
aux.poz = p;
muchii.push_back(aux);
}
sort(muchii.begin(), muchii.end());
for(auto muchie: muchii) {
int ra = rad(muchie.a);
int rb = rad(muchie.b);
if (ra != rb) {
sol.push_back(muchie.poz);
if (T[ra] < T[rb]) {
T[ra] += T[rb];
T[rb] = ra;
} else {
T[rb] += T[ra];
T[ra] = rb;
}
}
}
for (auto i: sol) {
fout << i << "\n";
}
}