Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.17 KB | None | 0 0
  1. //#define _CRT_SECURE_NO_WARNINGS
  2. //#pragma comment(linker,"/STACK:64000000")
  3. #include <stdio.h>
  4. #include <iostream>
  5. #include <math.h>
  6. #include <vector>
  7. #include <map>
  8. #include <set>
  9. #include <algorithm>
  10. #include <queue>
  11. #include <string>
  12. #include <string.h>
  13. #include <ctype.h>
  14. #include <iomanip>
  15. #include <iterator>
  16. #include <unordered_map>
  17. #include <unordered_set>
  18. #include <stdlib.h>
  19. #include <stack>
  20. #include <cstdio>
  21. #include <time.h>
  22.  
  23.  
  24. using namespace std;
  25.  
  26.  
  27. typedef long long ll;
  28. typedef pair<int, int> pii;
  29. typedef vector<int> vi;
  30. typedef vector<vi> vvi;
  31.  
  32.  
  33. #define all(x) x.begin(),x.end()
  34. #define mp make_pair
  35. #define eps 1e-7
  36. #define PI 3.14159265358979323846
  37. #define ACCEPTED return 0;
  38. #define optimize cin.sync_with_stdio(false);cout.sync_with_stdio(false);cin.tie(0);
  39.  
  40. const ll infinity = (ll) 1e18;
  41. #ifdef _DEBUG
  42.     const int maxlen = (int)(1e1) + 10;
  43. #else
  44.     const int maxlen = (int)(1e5) + 10;
  45. #endif
  46. const int base = (int)(1e9);
  47. const ll mod = base + 7;
  48.  
  49. #define name ""
  50.  
  51.  
  52. double dist(pair<double,double > a, pair<double,double > b)
  53. {
  54.     return (a.first-b.first)*(a.first-b.first) + (a.second-b.second)*(a.second-b.second);
  55. }
  56.  
  57. vector<pair<pair<double,double >,int>> pt;
  58. int cnt[20];
  59. vector<pair<double,int >> nh;
  60.  
  61. int main() {
  62. #ifdef _DEBUG
  63.     freopen("input.txt", "rt", stdin);
  64.     freopen("output.txt", "wt", stdout);
  65. /*#else
  66.   freopen(name".in", "rt", stdin);
  67.     freopen(name".out", "wt", stdout);*/
  68. #endif
  69.     optimize;
  70.  
  71.     double n, k, t;
  72.     cin >> n >> k >> t;
  73.     double x, y;
  74.     int c;
  75.     for (int i = 0; i < n; i++) {
  76.         cin >> x >> y >> c;
  77.         pt.push_back({{x, y}, c});
  78.     }
  79.     while (t-- > 0) {
  80.         memset(cnt, 0, sizeof(cnt));
  81.         nh.clear();
  82.         cin >> x >> y;
  83.         pair<double,double > cur = {x, y};
  84.         for (auto p:pt) {
  85.             nh.push_back({dist(p.first, cur), p.second});
  86.         }
  87.         sort(all(nh));
  88.         for (int i = 0; i < k; i++)
  89.             cnt[nh[i].second]++;
  90.         int ans = 0;
  91.         for (int i = 0; i < 20; i++)
  92.             if (cnt[i] > cnt[ans])
  93.                 ans = i;
  94.         cout << ans << endl;
  95.     }
  96.  
  97.  
  98.     ACCEPTED
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement