Pagini recente » Cod sursa (job #3362444) | Cod sursa (job #3362485) | Cod sursa (job #3362403) | Cod sursa (job #3362491) | Cod sursa (job #3362483)
#include <bits/stdc++.h>
#define f first
#define s second
#define float double
using namespace std;
ifstream fin ("adapost.in");
ofstream fout ("adapost.out");
int n, sink;
long long st, mij, dist, maxflux, cost, iuli, maxd;
float morariu, acc_dist, acc_cost;
pair <float, float> sld[405], adp[405];
struct much{
int c, f;
long long z;
};
much a[805][805];
int last[805];
long long d[805], dvechi[805], reald[805];
int cuplaj[805];
bool mrc[405];
bool say_gex(int nod, long long dist){ //say gex pt ca fac cupluri de noduri si atunci nodurile fac say gex lol
// si eu cu cezar bolba
// dar el e tsundere
//sunt taken bro sybau
// de mine bro
//ba nu de tudor vianu huzz
// nu mai suntem prieteni
//oricum suntem frati nu ai unde sa pleci
// ok you have a point
if(mrc[nod]) return 0;
mrc[nod] = 1;
for(int i = n + 1; i < sink; i++){
if(a[nod][i].z <= dist && (!cuplaj[i] || say_gex(cuplaj[i], dist))){
cuplaj[nod] = i;
cuplaj[i] = nod;
return 1;
}
}
return 0;
}
//scuzati cearta de mai sus
int fa_cuplaj(long long dist){
int rez = 0;
bool continua = 1;
for(int i = 1; i <= n; i++){
cuplaj[i] = 0;
cuplaj[n+i] = 0;
}
while(continua){
continua = 0;
for(int i = 1; i <= n; i++){
mrc[i] = 0;
}
for(int i = 1; i <= n; i++){
if(!cuplaj[i] && say_gex(i, dist)){
continua = 1;
rez++;
}
}
}
return rez;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
fin >> n;
sink = 2 * n + 1;
for(int i = 1; i <= n; i++){
fin >> sld[i].f >> sld[i].s;
a[0][i] = {1, 0, 0};
}
for(int i = 1; i <= n; i++){
fin >> adp[i].f >> adp[i].s;
for(int j = 1; j <= n; j++){
morariu = sqrt((adp[i].f - sld[j].f) * (adp[i].f - sld[j].f) +
(adp[i].s - sld[j].s) * (adp[i].s - sld[j].s));
morariu *= 10000;
iuli = morariu;
maxd = max(maxd, iuli);
a[j][n+i] = {1, 0, iuli};
a[n+i][j] = {0, 0, -iuli};
}
a[n+i][sink] = {1, 0, 0};
}
mij = 1;
while(mij < maxd) mij *= 2;
while(mij >= 1){
cout << st + mij << " ";
if(fa_cuplaj(st + mij) == n){
dist = st + mij;
}
else{
st += mij;
}
mij /= 2;
}
acc_dist = dist;
acc_dist /= 10000;
fout << acc_dist << " ";
return 0;
}