Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. #define TASKNAME "task"
  2. #include <iostream>
  3. #include <cstdio>
  4. #include <cstdlib>
  5. #include <string>
  6. #include <algorithm>
  7. #include <cassert>
  8. #include <cmath>
  9. #include <utility>
  10. #include <map>
  11. #include <set>
  12. #include <vector>
  13.  
  14.  
  15. #define MAXN int(1e3 + 10)
  16. #define pb push_back
  17. #define mp make_pair
  18. #define DB(x) cerr<<#x<<" = "<<(x)<<"\n"
  19. #define DB2(a,b)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
  20. #define out(x) cout<<(x)<<" "
  21. #define sz(A) (int)(A).size()
  22. #define pi 3.1415926535897932384626433832795
  23. #define sqr(a) ((a) * (a))
  24.  
  25. using namespace std;
  26.  
  27. struct point{
  28.   long long x, y;
  29. };
  30.  
  31.  
  32. long long dist(point a, point b){
  33.   return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
  34. }
  35.  
  36.  
  37. point pt[MAXN], bag, bag1;
  38. long long d[int(1e6) * 17], n;
  39. vector<int> path;
  40.  
  41.  
  42. int main()
  43. {
  44.   #ifndef ONLINE_JUDGE
  45.     freopen(TASKNAME".in", "r", stdin);
  46.     freopen(TASKNAME".out", "w", stdout);
  47.   #endif
  48.   cin >> bag.x >> bag.y;
  49.   cin >> n;
  50.   for(int i = 0; i < n; i++)
  51.     cin >> pt[i].x >> pt[i].y;
  52.   for(int mask = 0; mask < (1 << n); mask++){
  53.       for(int j = n - 1; j >= 0; j--)
  54.         if(((mask >> j) & 1) == 1 && !flag){
  55.           index = j;
  56.           flag = true;
  57.         }
  58.         else if(((mask >> j) & 1) == 1 && flag){
  59.           old
  60.           d[mask] = max(d[mask], d[old_mask] + dist(pt[index], pt[j]) + dist(bag, pt[index]) + dist(bag, pt[j]));
  61.         }
  62.    
  63.  
  64.   }
  65.    
  66.  
  67.  
  68.     printf("%I64d", d[(1 << n) - 1]);
  69. //  for(int i = 0; i < sz(path); i++)
  70. //    cout << path[i] << " ";   */
  71.   return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement