someone plz help me out of here.
why i am getting compil error??
my code is here
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
struct node{
int x,y;
}a[1010];
struct edge
{
int u,v;
double w;
bool operator <(const edge &p) const
{
return w<p.w;
}
};
int pr[1010];
vector<struct edge>e;
edge get;
int find_root(int x)
{
if(x==pr[x])
return x;
else
return pr[x]=find_root(pr[x]);
}
int mst(int n,int r)
{
int i,j;
double s1=0;
double s2=0;
int r1=0;
int r2=0;
int u=0,v=0;
edge temp;
for(i=0;i<e.size();i++)
{
temp=e;
u=find_root(temp.u);
v=find_root(temp.v);
if(u!=v)
{
if(temp.w<=r)
s1+=temp.w;
else
{
s2+=temp.w;
r2 ++;
}
pr=v;
}
}
int a=round(s1);
int b=round(s2);
cout<<(r2+1)<<" "<<a<<" "<<b<<endl;
}
int clr()
{
e.clear();
for(int i=0;i<1010;i++)
{
pr=0;
a.x=0;
a.y=0;
}
}
int main()
{
int i,j,k,l,n,m;
int t,r;
cin>>t;
int cas=1;
while(t--)
{
cin>>n>>r;
for(i=0;i<n;i++)
{
cin>>a.x>>a.y;
pr=i;
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
get.u=i;
get.v=j;
get.w=sqrt(pow((a.x-a[j].x),2)+pow((a.y-a[j].y),2));
e.push_back(get);
}
}
sort(e.begin(),e.end());
printf("Case #%d: ",cas);
mst(n,r);
cas++;
clr();
}
return 0;
}
11228 - Transportation system.
All about problems in Volume 112. If there is a thread about your problem, please use it. If not, create one with its number in the subject.
Moderator: Board moderators
Return to “Volume 112 (11200-11299)”
Jump to
- Real Time Contests and Last Minute Information
- ↳ General
- ↳ Real Time Clarification
- ↳ Fixing Mistakes
- ↳ HOWTOs
- ↳ Bugs and suggestions
- New system
- ↳ FAQ
- ↳ Bugs and suggestions
- Let's make some programs!
- ↳ Other words
- ↳ Algorithms
- ↳ New features
- Help on the Problemset
- ↳ Volume 1 (100-199)
- ↳ Volume 2 (200-299)
- ↳ Volume 3 (300-399)
- ↳ Volume 4 (400-499)
- ↳ Volume 5 (500-599)
- ↳ Volume 6 (600-699)
- ↳ Volume 7 (700-799)
- ↳ Volume 8 (800-899)
- ↳ Volume 9 (900-999)
- ↳ Volume 10 (1000-1099)
- ↳ Volume 11 (1100-1199)
- ↳ Volume 12 (1200-1299)
- ↳ Volume 13 (1300-1399)
- ↳ Volume 14 (1400-1499)
- ↳ Volume 15 (1500-1599)
- ↳ Volume 16 (1600-1699)
- ↳ Volume 17 (1700-1799)
- ↳ Volume 100 (10000-10099)
- ↳ Volume 101 (10100-10199)
- ↳ Volume 102 (10200-10299)
- ↳ Volume 103 (10300-10399)
- ↳ Volume 104 (10400-10499)
- ↳ Volume 105 (10500-10599)
- ↳ Volume 106 (10600-10699)
- ↳ Volume 107 (10700-10799)
- ↳ Volume 108 (10800-10899)
- ↳ Volume 109 (10900-10999)
- ↳ Volume 110 (11000-11099)
- ↳ Volume 111 (11100-11199)
- ↳ Volume 112 (11200-11299)
- ↳ Volume 113 (11300-11399)
- ↳ Volume 114 (11400-11499)
- ↳ Volume 115 (11500-11599)
- ↳ Volume 116 (11600-11699)
- ↳ Volume 117 (11700-11799)
- ↳ Volume 118 (11800-11899)
- ↳ Volume 119 (11900-11999)
- ↳ Volume 120 (12000-12099)
- ↳ Volume 121 (12100-12199)
- ↳ Volume 122 (12200-12299)
- ↳ Volume 123 (12300-12399)
- ↳ Volume 124 (12400-12499)
- ↳ Volume 125 (12500-12599)
- ↳ Volume 126 (12600-12699)
- ↳ Volume 127 (12700-12799)
- ↳ Volume 128 (12800-12899)
- ↳ Volume 129 (12900-12999)
- ↳ Volume 130 (13000-13099)
- ↳ Volume 131 (13100-13199)
- Help on languages
- ↳ C
- ↳ C++
- ↳ Pascal
- ↳ Java
- Off Topic
- ↳ Off topic (General chit-chat)
- Category
- ↳ ACM ICPC Archive Board