id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Solution {\npublic:\n struct TrieNode\n {\n TrieNode* bits[2];\n TrieNode()\n {\n for (int i = 0; i < 2; i++) {\n bits[i] = NULL;\n }\n }\n };\n class Trie\n {\n private:\n TrieNode* root;\n public:\n ...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Solution {\nprivate:\n class Trie {\n public:\n Trie(int bit_length)\n : bit_length_(bit_length)\n , nodes_() {\n new_node();\n }\n\n void update(int num, int d) {\n int curr = 0;\n for (int i = bit_length_ - 1; i >= 0; --i...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "struct Node{\n Node* links[2];\n\n bool containsKey(int bit){\n return(links[bit]!=NULL); \n }\n\n void put(int bit,Node* node){\n links[bit]=node;\n }\n\n Node* get(int bit){\n return links[bit];\n }\n\n\n};\n\nclass Trie{\n private: Node* root;\n public:...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Solution {\npublic:\n int maximumStrongPairXor(vector<int>& nums) \n {\n sort(rbegin(nums), rend(nums));\n int ans = -1;\n for(int i = 0; i<nums.size(); ++i)\n {\n for(int j = i; j<nums.size(); ++j)\n {\n if(abs(nums[i]-nums[j]) <...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Solution {\npublic:\n struct TrieNode\n {\n TrieNode* bits[2];\n TrieNode()\n {\n for (int i = 0; i < 2; i++) {\n bits[i] = NULL;\n }\n }\n };\n class Trie\n {\n private:\n TrieNode* root;\n public:\n ...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "struct trie {\n trie* left;\n trie* right;\n};\n\nvoid insert(int num, trie* root) {\n trie* node = root;\n\n for (int i = 31; i >= 0; i--) {\n int ith_bit = (num >> i) & 1;\n\n if (ith_bit) {\n if (node->left == NULL) {\n node->left = new trie();\n ...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Trie {\npublic:\n int freq;\n Trie* left;\n Trie* right;\n\n Trie() {\n freq = 0;\n left = NULL;\n right = NULL;\n }\n};\n\nclass Solution {\npublic:\n int insert(Trie* root, int num) {\n Trie* node = root;\n int n = 0;\n for(int i = 19; i >...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Solution {\npublic:\n int maximumStrongPairXor(vector<int>& nums) {\n int l=nums.size();\n vector<int> v;\n int s;\n for(int i=0;i<l;i++)\n {\n int s=0;\n for(int j=i;j<l;j++)\n {\n int r=min(nums[i],nums[j]);\n ...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Solution {\npublic:\n int maximumStrongPairXor(vector<int>& nums) {\n int n = nums.size();\n int maxi = INT_MIN;\n vector<int> ans;\n \n for (int i = 0; i < n; ++i) {\n for (int j = i; j < n; ++j) {\n int diff = abs(nums[i] - nums[j]);\n if (diff <= min(n...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Solution {\npublic:\n int maximumStrongPairXor(vector<int>& nums) {\n if(nums.size()==1){\n return 0;\n }\n vector<int> v;\n int answer;\n for(int i=0; i<nums.size()-1; i++){\n for(int j=i; j<nums.size(); j++){\n int k=nums[j]...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "struct Node {\n Node*links[2];\n int freq;\n Node() : freq(0) {\n links[0] = links[1] = NULL;\n }\n \n bool containsKey(int bit){\n return links[bit] != NULL;\n }\n void put(int bit, Node*node){\n links[bit] = node;\n }\n Node*get(int bit){\n return...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Solution {\npublic:\n struct TrieNode\n {\n TrieNode* bits[2];\n TrieNode()\n {\n for (int i = 0; i < 2; i++) {\n bits[i] = NULL;\n }\n }\n };\n class Trie\n {\n private:\n TrieNode* root;\n public:\n ...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Solution {\npublic:\n int maximumStrongPairXor(vector<int>& nums) {\n int x=0;\n priority_queue<int> pq;\n for(int i=0;i<nums.size();i++){\n for(int j=i;j<nums.size();j++){\n if(abs(nums[i]-nums[j])<=min(nums[i],nums[j])){\n x=nums[...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "struct TrieNode\n{\n int cnt[2];\n TrieNode *p[2];\n TrieNode()\n {\n cnt[0]=cnt[1]=0;\n p[0]=p[1]=nullptr;\n }\n};\n\nstruct Trie\n{\n const int MAXBIT=19;\n TrieNode *root;\n Trie()\n {\n root=new TrieNode;\n }\n void Insert(int a)\n {\n Tri...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Solution {\npublic:\n int maximumStrongPairXor(vector<int>& nums) {\n vector<pair<int, int>> vp;\n for (int i = 0; i < nums.size(); i++) {\n for (int j = i + 1; j < nums.size(); j++) {\n if (abs(nums[i] - nums[j]) <= min(nums[i], nums[j])) {\n vp.push_back({n...
3,193
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. A pair of integers <code>x</code> and <code>y</code> is called a <strong>strong</strong> pair if it satisfies the condition:</p> <ul> <li><code>|x - y| &lt;= min(x, y)</code></li> </ul> <p>You need to select two integers from <code>nums</...
3
{ "code": "class Solution {\npublic:\n int maximumStrongPairXor(vector<int>& nums) {\n vector<pair<int, int>> strongPairs;\n for (int i = 0; i < nums.size(); i++) {\n for (int j = i + 1; j < nums.size(); j++) {\n if (abs(nums[i] - nums[j]) <= min(nums[i], nums[j])) {\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
0
{ "code": "class Solution{\n int X, Y;\n static const int nmax = 1005;\n int p[nmax];\npublic:\n int get_p(int a)\n {\n if(p[a] == a)\n return a;\n return p[a] = get_p(p[a]);\n }\n\n void unite(int a, int b)\n { \n int pa = get_p(a);\n int pb = get_p(b)...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
0
{ "code": "class Solution{\n int X, Y;\n static const int nmax = 1005;\n int p[nmax];\npublic:\n int get_p(int a)\n {\n if(p[a] == a)\n return a;\n return p[a] = get_p(p[a]);\n }\n\n void unite(int a, int b)\n { \n int pa = get_p(a);\n int pb = get_p(b)...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
1
{ "code": "/**class Solution {\npublic:\n bool canReachCorner(int xCorner, int yCorner, vector<vector<int>>& circles) {\n const int n = static_cast<int>(circles.size());\n std::vector<int> id(n + 2), rank(n + 2);\n for (int i = 0; i < n + 2; ++i)\n id[i] = i;\n auto find = [&...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
1
{ "code": "class Solution {\npublic:\n int rx, ry;\n struct circle {\n long long x, y, r; \n };\n vector<circle> circle_list;\n int grp[1001];\n int type[1001]; \n\n bool f_circle_chk(circle &A, circle &B) {\n return (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y) <=...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
1
{ "code": "#include <bits/stdc++.h>\n#pragma GCC optimize(2)\n#define rep(i, a, b) for (int i = (a); i < (b); ++i)\n#define rep_(i, a, b) for (int i = (a); i > (b); i--)\n#define mst(x, a) memset(x, a, sizeof(x))\n#define all(a) begin(a), end(a)\n#define lowbit(x) ((x) & (-(x)))\n#define bitcnt(x) (__builtin_popcount...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
1
{ "code": "class Solution {\n struct DisjointSet {\n vector<int> parent;\n vector<int> size;\n\n DisjointSet(int maxSize) {\n parent.resize(maxSize);\n size.resize(maxSize);\n for (int i = 0; i < maxSize; i++) {\n parent[i] = i;\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n#define ll long long\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n \n auto intersect = [](int x1,int x2, int y1, int y2, int r1, int r2) {\n ll dx= x2-x1, dy=y2-y1, rs=r1+r2;\n ll dissq= dx*dx+dy*dy;\n retu...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\nprivate:\n bool is_same(const vector<int>& c1, const vector<int>& c2){\n long long dx = (c1[0]-c2[0]);\n long long dy = (c1[1]-c2[1]);\n long long d = (c1[2]+c2[2]);\n return dx*dx + dy*dy <= d*d;\n }\n int find(int i){\n if(roots[i]==-1 || root...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "#define printf(fmt, ...) (0)\n\n#define ll long long\n\nstruct UnionFind {\n vector<int> p;\n \n UnionFind(int n) {\n for (int i = 0; i < n; ++i) {\n p.push_back(i);\n }\n }\n \n int Find(int i) {\n if (p[i] != i) {\n p[i] = Find(p[i]);\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "const int N = 5000;\n\nvector<int> edges[N];\n\nvoid insert(int x, int y) {\n edges[x].push_back(y);\n edges[y].push_back(x);\n}\n\nvector<bool> bfs(int n, int source) {\n vector<bool> vis(n, false);\n vis[source] = true;\n queue<int> q;\n q.push(source);\n while (!q.empty()) {\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "const int N = 5000;\n\nvector<int> edges[N];\n\nvoid insert(int x, int y) {\n edges[x].push_back(y);\n edges[y].push_back(x);\n}\n\nvector<bool> bfs(int n, int source) {\n vector<bool> vis(n, false);\n vis[source] = true;\n queue<int> q;\n q.push(source);\n while (!q.empty()) {\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "// clang-format off\nstatic const auto io_sync_off = []() { ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();\nusing ll = long long; using SS = stringstream;\nusing pii = pair<int, int>; using pis = pair<int, string>; using psi = pair<string, int>;\ntemplate<typename T> using V = vector<T>; tem...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "// clang-format off\nstatic const auto io_sync_off = []() { ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();\nusing ll = long long; using SS = stringstream;\nusing pii = pair<int, int>; using pis = pair<int, string>; using psi = pair<string, int>;\ntemplate<typename T> using V = vector<T>; tem...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "// clang-format off\nstatic const auto io_sync_off = []() { ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();\nusing ll = long long; using SS = stringstream;\nusing pii = pair<int, int>; using pis = pair<int, string>; using psi = pair<string, int>;\ntemplate<typename T> using V = vector<T>; tem...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "// clang-format off\nstatic const auto io_sync_off = []() { ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();\nusing ll = long long; using SS = stringstream;\nusing pii = pair<int, int>; using pis = pair<int, string>; using psi = pair<string, int>;\ntemplate<typename T> using V = vector<T>; tem...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "// AAAAA N N U U JJJJJ\n// A A NN N U U J \n// AAAAAAA N N N U U J \n// A A N NN U U J J \n// A A N N UUU JJJ \ntemplate <typename A, typename B>\nostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << \", \" << p.sec...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n\n int par[10001];\n int rnk[10001];\n bool vis[10001];\n\n void initialise(){\n for(int i=0;i<=1000;i++){\n par[i]=i;\n rnk[i]=1;\n vis[i]=false;\n }\n }\n\n int findPar(int node){\n if(par[node]==node) retu...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool intersects(vector<int>& c1, vector<int> c2) {\n //\n long long dist = pow(c1[0] - c2[0], 2) + pow(c1[1] - c2[1], 2);\n\n return sqrt(dist) <= c1[2] + c2[2];\n }\n\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n queu...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "typedef long long ll;\n\nll sqr(ll x) {\n return x * x;\n}\n\nll dist(ll x, ll y, ll x2, ll y2) {\n return sqr(x - x2) + sqr(y - y2);\n}\n\nbool connected(ll x1, ll y1, ll r1, ll x2, ll y2, ll r2) {\n return sqr(r1 + r2) >= dist(x1, y1, x2, y2);\n}\n\nconstexpr ll MAXN = 1e3 + 5;\n\nll cooras[MAXN...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\n class DisjointSet {\n\npublic:\n // unordered_map<long long int,int>parent;\n vector<long long int> parent ,size;\n // unordered_map<long long int, long long int> size;\n \n // unordered_map<long long int, vector<long long int>> res;\n vector<...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "typedef long long ll;\n\nclass Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n int n = circles.size();\n bool visited[n];\n fill(visited, visited + n, 0);\n set<int> st;\n for (int i = 0; i < n; i++) {\n st.insert(i)...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "#include <bits/stdc++.h>\nusing namespace std;\ntypedef long long ll;\ntypedef vector<int> vi;\ntypedef pair<int,int> pii;\ntypedef pair<double, double> pdd;\n#define pb push_back\n#define mp make_pair\n#define fs first\n#define sc second\n#define rep(i, from, to) for (int i = from; i < (to); ++i)\n#define...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool dfs(int curr,vector<int>& visited,int X,vector<vector<int>>& circles)\n {\n visited[curr]=1;\n vector<int> temp=circles[curr];\n if(abs(X-temp[0])<=temp[2])\n return false;\n int n=circles.size();\n bool ans=true;\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n int x,y;\n long long square(int x){\n return 1LL*x*x;\n }\n bool fun(vector<int>&v){\n // cout<<v[0]<<endl;\n int r=v[2];\n if(v[0]>=0 and v[0]<=x and v[1]>=0 and v[1]<=y)return 1;\n if(v[0]>=0 and v[0]<=x){\n if(abs(v[1]...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "typedef long long ll;\nclass Solution {\npublic:\n\tbool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n\t\tll n = circles.size();\n\t\tvector<ll> f(n + 2);\n\t\tfor (ll i = 0; i < n + 2; i++) {\n\t\t\tf[i] = i;\n\t\t}\n\t\tfunction<ll(ll)> find = [&](ll i) {\n\t\t\tif (f[i] != i) {\n\t\t\t\...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "typedef long long ll;\nclass Solution {\npublic:\n\tbool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n\t\tll n = circles.size();\n\t\tvector<ll> f(n + 2);\n\t\tfor (ll i = 0; i < n + 2; i++) {\n\t\t\tf[i] = i;\n\t\t}\n\t\tfunction<ll(ll)> find = [&](ll i) {\n\t\t\tif (f[i] != i) {\n\t\t\t\...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n int n = circles.size();\n vector<int> startCircles, endCircles;\n \n for (int i = 0; i < n; i++) {\n int x = circles[i][0], y = circles[i][1], R = circles[i][2];\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n // Define a structure to represent a circle\n struct Circle {\n int x, y, r;\n Circle(int xi, int yi, int ri) : x(xi), y(yi), r(ri) {}\n };\n\n // Function to check if two circles intersect\n bool doIntersect(const Circle& c1, const Circle& c2) {\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n void dfs(int v, vector<bool>& used, vector<vector<int>>& g) {\n used[v] = 1;\n for (int to: g[v]) {\n if (!used[to])\n dfs(to, used, g);\n }\n }\n\n bool canReachCorner(int X, int Y, vector<vector<int>>& a) {\n int n...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\n bool bfs(vector<vector<int>>& adj, int dep, int dest) {\n queue<int> que;\n vector<bool> vis(adj.size(), false);\n que.push(dep);\n vis[dep] = true;\n\n while (!que.empty()) {\n int from = que.front();\n que.pop();\n\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n\n #define max_size 1005\n vector<int> parent,size_;\n vector<vector<int>> bd; \n\n // L,R,D,U\n\n int find_set(int v) {\n if (v == parent[v])\n return v;\n return parent[v] = find_set(parent[v]);\n }\n\n void make_set(int v) {\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n int n = circles.size();\n vector<vector<int>> graph(n);\n\n // Function to check if two circles touch or overlap\n auto circlesTouch = [&](int i, int j) {\n long long x1...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\nlong long distancesq(long long x1,long long y1,long long x2,long long y2){\n return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);\n}\nbool isb(double x1, double y1, double r1, double x2, double y2, double r2,\ndouble tb,double rb) {\n double d = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n \n bool circlesMeet(int X, int Y, int i, int j, vector<vector<int>>& circles) {\n double x1 = (circles[i][0]);\n double x2 = (circles[j][0]);\n double y1 = circles[i][1];\n double y2 = circles[j][1];\n double r1 = circles[i][2];\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n vector<int> adj[1005];\n bool intersect(vector<int>& c1, vector<int>& c2)\n {\n long long d1 = (c1[0]-c2[0])*1LL*(c1[0]-c2[0]) + (c1[1]-c2[1])*1LL*(c1[1]-c2[1]);\n \n long long d2 = (c1[2]+c2[2])*1LL*(c1[2]+c2[2]);\n \n return d2 >= d1...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool fn(const vector<int>& circle1, const vector<int>& circle2,int &x,int &y) {\n double x1 = circle1[0], y1 = circle1[1], r1 = circle1[2];\n double x2 = circle2[0], y2 = circle2[1], r2 = circle2[2];\n\n // Calculate the distance between the centers\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n#define ll long long\nbool dfs(vector<int> &vec,vector<vector<int>>& circles, map<vector<int>,int> &vis, int X) {\n ll x = vec[0],y = vec[1],r = vec[2];\n vis[vec] = 1;\n if (y <= r || X <= (r+x)) return true;\n \n for (auto v:circles) {\n ll xx = v[0],yy = ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool check(long long x,long long y,long long xx,long long yy,long long r,long long rr){\n long long d = 1LL*abs(x-xx)*abs(x-xx) + 1LL*abs(y-yy)*abs(y-yy); \n long long dc = (r+rr)*(r+rr);\n if(dc>=d){\n return true;\n }\n return f...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "#define ll long long\nclass Solution {\npublic:\n ll findParent(ll u, vector<ll>& parent){\n if(u != parent[u]){\n return parent[u] = findParent(parent[u], parent);\n }\n return parent[u];\n }\n void Union(ll u, ll v, vector<ll>& parent){\n ll pu = findParent...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\n \n bool bfs(int node,vector<int>&v, vector<vector<int>>&adj, vector<int>&vis){\n set<int>s;\n s.insert(v[node]);\n \n queue<int>q;\n q.push(node);\n vis[node]=1;\n \n while(!q.empty()){\n int t=q.front();\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "using ll = long long;\n\nstatic constexpr int N = 1003;\n\nclass Solution {\npublic:\n vector<int> adj[N];\n bool isA[N], isB[N], visited[N];\n\n bool isCrossingY(vector<int>& circle, int Y) {\n // distance line to circle <= r\n int x = circle[0], y = circle[1], r = circle[2];\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n map<int,int> ml,mr;\n vector<int> adj[circles.size()];\n for(int i=0;i<circles.size();i++){\n int r=circles[i][2];\n if(circles[i][0]-r<=0 || circles[i][1]+r>=Y)\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\n vector<vector<int>> touch;\n vector<bool> boundary;\n vector<bool> otherBoundaries;\n vector<bool> vis;\n\n double distance(int x1, int y1, int x2, int y2)\n {\n double d1 = x1 - x2;\n double d2 = y1 - y2;\n return sqrt(d1 * d1 + d2 * d2);\n }\n\...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n vector<vector<int>> ind(1001);\n map<int,int> hm;\n vector<vector<int>> p(1001, vector<int>(4));\n int n = 0;\n for(int i = 0; i < circles.size(); i++){\n for(int...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "const int maxn = 1e3 + 5;\nint p[maxn], v[maxn];\ntypedef double db;\nconst db eps = 1e-8;\nint dcmp(const db& x)\n{\n if(fabs(x) < eps) return 0;\n else return x > 0 ? 1 : -1;\n}\nconst db PI = acos(-1);\nstruct Pnt\n{\n db x, y;\n Pnt(const db x = 0, const db y = 0) : x(x), y(y) {}\n Pnt(c...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool overlapped(vector<int>& c1, vector<int>& c2){\n return (long long) (c2[0] - c1[0])*(c2[0] - c1[0]) + \n (long long) (c2[1] - c1[1])*(c2[1] - c1[1]) <= \n (long long) (c1[2] + c2[2])*(c1[2] + c2[2]);\n }\n pair<bool, bool> dfs(int i, vec...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool overlapped(vector<int>& c1, vector<int>& c2){\n return (long long) (c2[0] - c1[0])*(c2[0] - c1[0]) + \n (long long) (c2[1] - c1[1])*(c2[1] - c1[1]) <= \n (long long) (c1[2] + c2[2])*(c1[2] + c2[2]);\n }\n pair<bool, bool> dfs(int i, vec...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n using ll = long long;\n\n bool intersects(vector<int> &circleA, vector<int> &circleB) {\n ll aX = circleA[0], aY = circleA[1], aR = circleA[2];\n ll bX = circleB[0], bY = circleB[1], bR = circleB[2];\n\n // Calculate the distance between the centers of...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool touchesx(vector<int>& v) { return v[1] == v[2]; }\n\n bool touchesy(vector<int>& v) { return v[0] == v[2]; }\n\n bool touchesxx(vector<int>& v, int X) { return abs(X - v[0]) == v[2]; }\n\n bool touchesyy(vector<int>& v, int Y) { return abs(Y - v[1]) == v[2]; }\n...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool touchesx(vector<int>& v) { return v[1] == v[2]; }\n\n bool touchesy(vector<int>& v) { return v[0] == v[2]; }\n\n bool touchesxx(vector<int>& v, int X) { return abs(X - v[0]) == v[2]; }\n\n bool touchesyy(vector<int>& v, int Y) { return abs(Y - v[1]) == v[2]; }\n...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n int n = circles.size();\n vector<int> adj[n];\n for(int i = 0;i < circles.size();i++){\n for(int j = i+1;j < circles.size();j++){\n int rdist = abs(circles[i][2]...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n int n = circles.size();\n vector<int> adj[n];\n for(int i = 0;i < circles.size();i++){\n for(int j = i+1;j < circles.size();j++){\n int rdist = abs(circles[i][2]...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n int n = circles.size();\n std::vector<std::vector<int>> edges(n+4);\n\n // build graph\n for (size_t i = 0; i < circles.size(); i++) {\n int xi = circles[i][0], yi = cir...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool check(int node1,int node2, vector<set<int>> &v){\n if((v[0].count(node1) && v[2].count(node2)) or (v[2].count(node1) && v[0].count(node2))) return false;\n if((v[0].count(node1) && v[3].count(node2)) or (v[3].count(node1) && v[0].count(node2))) return false...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n int n = circles.size();\n std::vector<std::vector<int>> edges(n+4);\n\n // build graph\n for (size_t i = 0; i < circles.size(); i++) {\n int xi = circles[i][0], yi = cir...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n int n = circles.size();\n std::vector<std::vector<int>> edges(n+4);\n\n // build graph\n for (size_t i = 0; i < circles.size(); i++) {\n int xi = circles[i][0], yi = cir...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n int n = circles.size();\n std::vector<std::vector<int>> edges(n+4);\n\n // build graph\n for (size_t i = 0; i < circles.size(); i++) {\n int xi = circles[i][0], yi = cir...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n using ll = long long;\n bool canReachCorner(int X, int Y, vector<vector<int>>& circle) {\n int n = circle.size();\n\n auto check = [&](vector<int>& c) {\n ll dx = abs(c[0] - 0), dy = abs(c[1] - 0);\n ll t = c[2];\n if (dx * dx...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "typedef long long ll;\nclass Solution {\n static auto touch_z(auto &c, ll X, ll Y, bool do_swap) {\n ll x = c[0];\n ll y = c[1];\n ll r = c[2];\n if (do_swap) {\n swap(x, y);\n swap(X, Y);\n }\n if (x == r)\n return y <= Y;\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n double dist(long x, long y, long a, long b){\n return sqrt((a-x)*(a-x)+(b-y)*(b-y));\n }\n bool canReachCorner(int X, int Y, vector<vector<int>>& c) {\n \n map<vector<int>, int> mp;\n for(auto it: c) mp[it]++;\n \n c.clear();\n...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Graph {\n public:\n int n; \n vector<vector<int>> adj;\n vector<bool> visited;\n\n vector<int> hits_top; // if circle[i] hits top or not\n vector<int> hits_right;\n vector<int> hits_bot;\n vector<int> hits_left;\n\n vector<array<int, 2>> top_lefts;\n vector<array<int, 2>...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool circlesTouch(vector<int>&a, vector<int>&b){\n long long sum=0;\n sum+=(long long)abs(a[0]-b[0])*abs(a[0]-b[0]);\n sum+=(long long)abs(a[1]-b[1])*abs(a[1]-b[1]);\n long long radius=((long long)a[2]+b[2])*(a[2]+b[2]);\n if(sum<=radius)\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "#define ll long long\nclass Solution {\npublic:\n\n bool touchOrIntersect(const vector<int>& circle1, const vector<int>& circle2) {\n int x1 = circle1[0], y1 = circle1[1], r1 = circle1[2];\n int x2 = circle2[0], y2 = circle2[1], r2 = circle2[2];\n long long distSq = (ll)(x1 - x2) * ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n // set<int> rightSide, topSide;\n // set<int> leftSide, bottomSide;\n bool dfs(int i, vector<int> adj[], unordered_set<int> &s1, unordered_set<int> &s2, vector<int> &vis) {\n vis[i] = 1;\n if(s1.find(i) != s1.end() || s2.find(i) != s2.end()) {\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n long long sqr(int x) {\n long long res = x;\n return res * res;\n }\n vector<int> intersectingPoints(int X, int Y, vector<int>& circle) {\n vector<int> dir = {0,0,0,0};\n int x = circle[0], y = circle[1], r = circle[2];\n if(sqr(y) <= ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n // set<int> rightSide, topSide;\n // set<int> leftSide, bottomSide;\n bool dfs(int i, vector<int> adj[], set<int> &s1, set<int> &s2, vector<int> &vis) {\n vis[i] = 1;\n if(s1.find(i) != s1.end() || s2.find(i) != s2.end()) {\n return true;\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n // set<int> rightSide, topSide;\n // set<int> leftSide, bottomSide;\n bool dfs(int i, vector<int> adj[], set<int> &s1, set<int> &s2, vector<int> &vis) {\n vis[i] = 1;\n if(s1.find(i) != s1.end() || s2.find(i) != s2.end()) {\n return true;\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "// assuming each circle has its centre inside the rectangle!\n\nclass Solution {\npublic:\n typedef array<int, 4> Line;\n \n bool areCirclesIntersecting(int x1, int y1, int r1, int x2, int y2, int r2){\n double distance = sqrt(1LL * (x2 - x1) * (x2 - x1) + 1LL * (y2 - y1) * (y2 - y1));\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n int findHead(int i, vector<int>& groups) {\n if (groups[i] == -1) {\n return i;\n }\n return groups[i] = findHead(groups[i], groups);\n }\n void unionGroup(int i, int j, vector<int>& groups) {\n int h1 = findHead(i, groups);\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n void makeEdge(vector<vector<int>>& edges, int i,int j,vector<vector<int>>& circles){\n long long a,b,r;\n a=circles[i][0]-circles[j][0];\n b=circles[i][1]-circles[j][1];\n r=circles[i][2]+circles[j][2];\n\n long long distanceSq = (a*a)+(b*b)...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n void makeEdge(vector<vector<int>>& edges, int i,int j,vector<vector<int>>& circles){\n long long a,b,r;\n a=circles[i][0]-circles[j][0];\n b=circles[i][1]-circles[j][1];\n r=circles[i][2]+circles[j][2];\n\n long long distanceSq = (a*a)+(b*b)...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "#include <vector>\n#include <cmath>\n#include <algorithm>\n\nusing namespace std;\n\nclass Solution {\npublic:\n bool canReachCorner(int X, int Y, vector<vector<int>>& circles) {\n const int n = circles.size();\n vector<vector<int>> als(n);\n \n for (int i = 0; i < n; ++i) {\...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n vector<long long> side(vector<int> circle, long long X, long long Y)\n {\n vector<long long>res;\n if (circle[0]-circle[2]<=0) res.push_back(1);\n if (circle[0]+circle[2]>=X) res.push_back(2);\n if (circle[1]-circle[2]<=0) res.push_back(3);\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool traverse(vector<int> g[],int i,int a,int b,vector<bool>&vis){\n vis[i]=true;\n \n for(auto j: g[i]){\n if(vis[j]==false){\n // cout<<j<<\" \"<<a<<\" \"<<b<<\" \"<<c<<endl;\n if(j==a || j==b)return true;\n ...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "using ld=long double;\n#define sq(x) (ld(x)*ld(x))\n\nbool dfs(int i, int tr, vector<vector<int>> &g, vector<int> &vis) { //O(n^2)\n if (i==tr) return 1;\n vis[i]=1;\n for (auto &v:g[i]) if (!vis[v]) \n if (dfs(v,tr,g,vis)) return 1;\n return 0;\n}\n\npair<pair<ld,ld>,pair<ld,ld>> get_in...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n #define ll long long\n \n void dfs(ll node,vector<ll>&vis,vector<int>adj[],vector<vector<ll>>&v,vector<ll>&res){\n vis[node]=1;\n \n ll r=v[node][2];\n res[0]=min(res[0],v[node][0]-r);\n res[1]=max(res[1],v[node][0]+r);\n res[2]...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "#define ll long long int\nclass Solution {\npublic:\n //Graph \n //Start from left ya top end bottom ya right \n //Touch means Connected \n bool check(ll a,ll b,ll c,ll X,ll Y,ll ck){\n ll x;\n ll y;\n if(ck==0){\n x=min(a,X);\n y=Y;\n x=abs...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n #define ll long long\n \n void dfs(ll node,vector<ll>&vis,vector<int>adj[],vector<vector<ll>>&v,vector<ll>&res){\n vis[node]=1;\n \n ll r=v[node][2];\n res[0]=min(res[0],v[node][0]-r);\n res[1]=max(res[1],v[node][0]+r);\n res[2]...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n #define ll long long\n \n void dfs(ll node,vector<ll>&vis,vector<int>adj[],vector<vector<ll>>&v,vector<ll>&res){\n vis[node]=1;\n \n ll r=v[node][2];\n res[0]=min(res[0],v[node][0]-r);\n res[1]=max(res[1],v[node][0]+r);\n res[2]...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool canReachCorner(int xCorner, int yCorner, vector<vector<int>>& circles) {\n int n = circles.size();\n\n // Create graph containing nodes for each circle and rect face\n // Nodes [0, n-1] are circles[0, n - 1]\n // Node n, n + 1, n + 2, n + 3 are the to...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\nvector<int> adj[1003];\nbool visited[1003];\npublic:\n bool dfs(int i, int right, int top, vector<vector<int>>& circles, bool & l, bool & b, bool & r, bool & t)\n {\n if(visited[i])\n {\n return false;\n }\n visited[i] = true;\n long lon...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class DSU{\n public:\n vector<int>par;\n DSU(int n){\n par.resize(n);\n for(int i=0;i<n;i++){\n par[i]=i;\n }\n }\n int find(int a){\n if(par[a]!=a){\n return par[a]=find(par[a]);\n }\n return a;\n }\n void Union...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "const int N = 1e3+1;\n\nclass Solution {\nprivate:\n vector<int> graph[N];\n bool v[N];\n\n bool is_overlapping(vector<int>& a, vector<int>& b) {\n long long x_diff = abs(a[0] - b[0]);\n long long y_diff = abs(a[1] - b[1]);\n return (sqrt(((x_diff) * (x_diff)) + ((y_diff) * (y...
3,478
<p>You are given two positive integers <code>xCorner</code> and <code>yCorner</code>, and a 2D array <code>circles</code>, where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> denotes a circle with center at <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code>.</p> ...
2
{ "code": "class Solution {\npublic:\n bool check(int i,int j, vector<vector<int>>& circles){\n long long x1 = circles[i][0],y1 = circles[i][1], r1 = circles[i][2];\n long long x2 = circles[j][0],y2 = circles[j][1], r2 = circles[j][2];\n return ((r1 + r2)*(r1+r2) >= ((x1-x2)*(x1-x2)) + ((y1-y2...