Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define TASKNAME "task"
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <string>
- #include <algorithm>
- #include <cassert>
- #include <cmath>
- #include <utility>
- #include <map>
- #include <set>
- #include <vector>
- #define MAXN int(1e3 + 10)
- #define pb push_back
- #define mp make_pair
- #define DB(x) cerr<<#x<<" = "<<(x)<<"\n"
- #define DB2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
- #define out(x) cout<<(x)<<" "
- #define sz(A) (int)(A).size()
- #define pi 3.1415926535897932384626433832795
- #define sqr(a) ((a) * (a))
- using namespace std;
- struct point{
- long long x, y;
- };
- long long dist(point a, point b){
- return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
- }
- point pt[MAXN], bag, bag1;
- long long d[int(1e6) * 17], n;
- vector<int> path;
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen(TASKNAME".in", "r", stdin);
- freopen(TASKNAME".out", "w", stdout);
- #endif
- cin >> bag.x >> bag.y;
- cin >> n;
- for(int i = 0; i < n; i++)
- cin >> pt[i].x >> pt[i].y;
- for(int mask = 0; mask < (1 << n); mask++){
- for(int j = n - 1; j >= 0; j--)
- if(((mask >> j) & 1) == 1 && !flag){
- index = j;
- flag = true;
- }
- else if(((mask >> j) & 1) == 1 && flag){
- old
- d[mask] = max(d[mask], d[old_mask] + dist(pt[index], pt[j]) + dist(bag, pt[index]) + dist(bag, pt[j]));
- }
- }
- printf("%I64d", d[(1 << n) - 1]);
- // for(int i = 0; i < sz(path); i++)
- // cout << path[i] << " "; */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement