fork download
  1. #ifdef _WIN32
  2. #include "stdc++.h"
  3. #define _CRT_SECURE_NO_WARNINGS
  4. #else
  5. #include <bits/stdc++.h>
  6. #endif
  7.  
  8. #include <map>
  9.  
  10. #define in_range(i, l, r) for(int i=l; i<r; i++)
  11. #define pb push_back
  12. #define all(v) v.begin(), v.end()
  13. #define fst first
  14. #define scd second
  15.  
  16. typedef long long ll;
  17. typedef pair<int, int> pii;
  18. typedef pair<ll, ll> pll;
  19.  
  20. using namespace std;
  21.  
  22. int ms[1000][1000];
  23. int used[1000];
  24. int n;
  25.  
  26. int bfs(int v) {
  27. int res = 0;
  28. queue<int> q;
  29. q.push(v);
  30. res++;
  31. used[v] = 1;
  32. while (!q.empty()) {
  33. int curr = q.front();
  34. q.pop();
  35. in_range(i, 0, n) {
  36. if (used[i] || !ms[curr][i]) continue;
  37. used[i] = 1;
  38. q.push(i);
  39. res++;
  40. }
  41. }
  42. return res;
  43. }
  44.  
  45. void run() {
  46. ll d;
  47. cin >> n>>d;
  48. vector<pll> stations;
  49. in_range(i, 0, n) {
  50. ll x, y;
  51. cin >> x >> y;
  52. stations.pb(make_pair(x, y));
  53. }
  54. in_range(i, 0, n) {
  55. in_range(j, i+1, n) {
  56. ll a = stations[i].fst - stations[j].fst;
  57. ll b = stations[i].scd - stations[j].scd;
  58. if (a*a + b * b > d*d) continue;
  59. ms[i][j] = ms[j][i] = 1;
  60. }
  61. }
  62. int res = -1;
  63. in_range(i, 0, n) {
  64. if (used[i]) continue;
  65. res = max(res, bfs(i));
  66. }
  67. cout << res << endl;
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. int main()
  81. {
  82. ios_base::sync_with_stdio(false);
  83. //freopen("out.txt", "w", stdout);
  84. run();
  85.  
  86. #ifdef _WIN32
  87. system("pause");
  88. #endif
  89. return 0;
  90. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5 1
1 2
1 3
2 4
3 5
4 12
compilation info
prog.cpp:17:9: error: ‘pair’ does not name a type
 typedef pair<int, int> pii;
         ^~~~
prog.cpp:18:9: error: ‘pair’ does not name a type
 typedef pair<ll, ll> pll;
         ^~~~
prog.cpp: In function ‘void run()’:
prog.cpp:48:9: error: ‘pll’ was not declared in this scope
  vector<pll> stations;
         ^~~
prog.cpp:48:12: error: template argument 1 is invalid
  vector<pll> stations;
            ^
prog.cpp:48:12: error: template argument 2 is invalid
prog.cpp:11:12: error: request for member ‘push_back’ in ‘stations’, which is of non-class type ‘int’
 #define pb push_back
            ^
prog.cpp:52:12: note: in expansion of macro ‘pb’
   stations.pb(make_pair(x, y));
            ^~
prog.cpp:56:21: error: invalid types ‘int[int]’ for array subscript
    ll a = stations[i].fst - stations[j].fst;
                     ^
prog.cpp:56:39: error: invalid types ‘int[int]’ for array subscript
    ll a = stations[i].fst - stations[j].fst;
                                       ^
prog.cpp:57:21: error: invalid types ‘int[int]’ for array subscript
    ll b = stations[i].scd - stations[j].scd;
                     ^
prog.cpp:57:39: error: invalid types ‘int[int]’ for array subscript
    ll b = stations[i].scd - stations[j].scd;
                                       ^
stdout
Standard output is empty