Pagini recente » Cod sursa (job #3148446) | Cod sursa (job #2968794) | Cod sursa (job #2268019) | Cod sursa (job #891817) | Cod sursa (job #2020519)
#include <bits/stdc++.h>
using namespace std;
#define pii pair< pair < long long , long long > , pair < int , int > >
vector<pii > g[200001];
bool vi[200001];
void prim(int s)
{
priority_queue<pii> h;
pii x;
vi[s]=true;
for(int i=0;i<g[s].size(); i++)
{
s=g[s][i];
h.push(x);
}
while(!h.empty())
{
x=h.top();
h.pop();
if(vi[x.second.first]) continue;
printf("%d\n",x.second.second);
s=x.second.first;
vi[s]=true;
for(int i=0;i<g[s].size(); i++)
{
x=g[s][i];
h.push(x);
}
}
}
int main()
{
freopen("lazy.in","r",stdin);
freopen("lazy.out","w",stdout);
int n,m,t1,t2;
long long t3,t4;
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
pii x;
scanf("%d %d %lld %lld",&t1,&t2,&t3,&t4);
x.first.first=-t3;
x.first.second=t4;
x.second.first=t2;
x.second.second=i;
x.first.first=-t3;
x.first.second=t4;
x.second.first=t1;
x.second.second=i;
g[t2].push_back(x);
}
prim(1);
fclose(stdout);
}