Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <vector>
- #include <cmath>
- #include <string>
- #include <algorithm>
- #include <string>
- #include <string.h>
- #define F first
- #define S second
- using namespace std;
- vector <pair <int, int> > a;
- double g[100][100], f[100][100];
- bool p[100];
- int vg(long x, long y)
- {
- bool f = true;
- //int r;
- for (int j = 0; j < a.size(); j++)
- {
- //cout << x << " " << y << "*" << a[j].F << " " << a[j].S << endl;
- if (a[j].F == x && a[j].S == y)
- {
- //cout <<a[j].F << " " << x << " " << a[j].S << " " << y << " oi vse" << endl;
- return j;
- }
- /*if (a[j].F == x)
- if (a[j].S == y)
- {
- cout << "&" ;
- r = j;
- }*/
- }
- //if (f)
- //{
- a.push_back(make_pair(x, y));
- return a.size() - 1;
- //}
- //cout << r << "%" << endl;
- //return r;
- }
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
- int n;
- cin >> n;
- //for (int i = 0; i < n*2; i++)
- // for (int j= 0; j < n*2; j++)
- // g[i][j] = 0;
- int k = 0;
- int l, m;
- //a.push_back(make_pair(0, 0));
- int x1, y1, x3, y3, x2, y2;
- double t;
- /*cin >> x1 >> y1 >> x3 >> y3 >> t;
- x1 *= 2; y1 *= 2; x3 *= 2; y3 *= 2; t /= 2;
- x2 = (x1 + x3) / 2; y2 = (y1 + y3) / 2;
- k = vg(x1, y1);
- l = vg(x2, y2);
- m = vg(x3, y3);
- //p[k] = true; p[m] = true;
- g[k][l] = t; g[l][k] = t;
- g[l][m] = t; g[m][l] = t;
- //k = m;
- */
- for (int i = 0; i < n; i++)
- {
- cin >> x1 >> y1 >> x3 >> y3 >> t;
- x1 *= 2; y1 *= 2; x3 *= 2; y3 *= 2; t /= 2;
- x2 = (x1 + x3) / 2; y2 = (y1 + y3) / 2;
- //if (vg(x1, y1) == a.size() - 1)
- // a.push_back(make_pair(x1, y2));
- k = vg(x1, y1);
- l = vg(x2, y2);
- m = vg(x3, y3);
- //p[i] = true;
- //p[k] = true; p[m] = true;
- g[k][l] = t; g[l][k] = t;// f[l][k] = t; f[k][l] = t;
- g[l][m] = t; g[m][l] = t;// f[m][l] = t; f[l][m] = t;
- //k = m;
- }
- //cout << x1 << " " << y1 << " " << x3 << " " <<y3 << endl;
- n = a.size();
- //cout << n << endl;
- /*for (int i = 0; i < n; i++)
- cout << a[i].F << " " << a[i].S << endl;
- cout << endl;
- */
- for (int i= 0; i < n; i++)
- {
- for (int j= 0; j < n; j++)
- cout << g[i][j] << " ";
- cout << endl;
- }
- cout << endl;
- for (int u = 0; u < n; u++)
- for (int i= 0; i < n; i++)
- for (int j= 0; j < n; j++)
- {
- //cout << g[i][j] << " " << g[i][u] << " " << g[u][j] << " ";
- if (g[i][u] && g[u][j])
- if (g[i][j] > g[i][u] + g[u][j] || (g[i][j] == 0 && i != j) )
- g[i][j] = g[i][u] + g[u][j];
- //cout << g[i][j] << endl;
- }
- for (int i= 0; i < n; i++)
- {
- for (int j= 0; j < n; j++)
- cout << g[i][j] << " ";
- cout << endl;
- }
- cout << endl;
- double ans = 10000000000000;
- int ans1, ans2, ans11, ans22;
- for (int i= 0; i < n; i++)
- {
- //if (!p[i])
- // continue;
- if (a[i].F % 2 == 0 && a[i].S % 2 == 0)
- {
- double mxm = -1000;
- for (int j = 0; j < n; j++)
- {
- //cout << g[i][j] << endl;
- if (g[i][j] > mxm)
- {
- mxm = g[i][j];
- ans1 = a[i].F / 2;
- ans2 = a[i].S / 2;
- }
- cout << mxm << " " << ans1 << " " << ans2 << " " << a[j].F << " " << a[j].S << endl;
- }
- //cout << mxm << " " << ans1 << " " << ans2 << endl;
- if (mxm >= 0 && mxm < ans)
- {
- ans = mxm;
- ans11 = ans1;
- ans22 = ans2;
- }
- }
- //ans = min(ans, mxm);
- }
- cout << ans11 << " " << ans22 << endl;
- printf("%.2f", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement