Pagini recente » Cod sursa (job #349844) | Cod sursa (job #2180892) | Cod sursa (job #2418751) | Cod sursa (job #714852) | Cod sursa (job #544065)
Cod sursa(job #544065)
#include<stdio.h>
#include<algorithm>
using namespace std;
struct muchie{
int a,b,ind;
long long c1,c2;
}mu[200100];
struct cmp{
bool operator()(muchie x,muchie y){
if(x.c1>y.c1)
return false;
if(x.c1<y.c1)
return true;
if(x.c2<y.c2)
return true;
return false;
}
};
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,cnt=0;
for(i=1;i<=M;++i){
x=par(mu[i].a);
y=par(mu[i].b);
if(x==y)
continue;
++cnt;
tata[x]=y;
printf("%d\n",mu[i].ind);
}
}
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();
fclose(stdin);
fclose(stdout);
return 0;
}