Pagini recente » Cod sursa (job #1272556) | Cod sursa (job #2008039) | Monitorul de evaluare | Monitorul de evaluare | Cod sursa (job #544049)
Cod sursa(job #544049)
#include<stdio.h>
#include<algorithm>
using namespace std;
struct muchie{
int a,b,ind;
long long c1,c2;
}mu[200100];
struct cmp{
bool operator()(const muchie &x,const muchie &y){
if(x.c1>y.c1)
return false;
if(x.c1<y.c1)
return true;
if(x.c2>y.c2)
return false;
return true;
}
};
int N,M,tata[200100];
char sol[200100];
int par(int x){
if(!tata[x])
return x;
return tata[x]=par(tata[x]);
}
void solve(){
int i,x,y;
for(i=1;i<=M;++i){
x=par(mu[i].a);
y=par(mu[i].b);
if(x==y)
continue;
tata[x]=y;
sol[mu[i].ind]=1;
}
}
int main(){
freopen("lazy.in","r",stdin);
freopen("lazy.out","w",stdout);
int i;
scanf("%d%d",&N,&M);
for(i=1;i<=M;++i){
scanf("%d%d%lld%lld",&mu[i].a,&mu[i].b,&mu[i].c1,&mu[i].c2);
mu[i].ind=i;
}
sort(mu+1,mu+M+1,cmp());
solve();
for(i=1;i<=M;++i){
if(sol[i])
printf("%d\n",i);
}
fclose(stdin);
fclose(stdout);
return 0;
}