{"kind":"task","effective_mode":"full","benchmark":{"kind":"benchmark","effective_mode":"full","slug":"livecodebench","formal_name":"LiveCodeBench","introduction":"LiveCodeBench continuously collects new competitive-programming problems to evaluate coding capabilities. Its initial release_v1 contains 400 problems, with source platform, contest date, and dataset version tracked explicitly.","introduction_ja":"","introduction_en":"","category":"Category not supplied","task_count":null,"acquisition_status":"Acquisition status not supplied","official_url":"https://livecodebench.github.io/","indexing_mode":"noindex","profile":{"resources":[],"task_format":"","scoring":"","metric":"","size":"","answer_access":"","license":"","citation":"","maintainer":"","released":"","why_hard":"","related":[]}},"task_id":"90628dcf-d809-50b5-ba1b-e0e5511b1d99","task_key":"release~5fv1--test--2827","task_revision_id":"1","upstream_id":"2827","short_description":"greatest-common-divisor-traversal","config":"release_v1","split":"test","body":"{\"contest_date\":\"2023-05-27T00:00:00\",\"contest_id\":\"biweekly-contest-105\",\"difficulty\":\"hard\",\"platform\":\"leetcode\",\"question_content\":\"You are given a 0-indexed integer array nums, and you are allowed to traverse between its indices. You can traverse between index i and index j, i != j, if and only if gcd(nums[i], nums[j]) > 1, where gcd is the greatest common divisor.\\nYour task is to determine if for every pair of indices i and j in nums, where i < j, there exists a sequence of traversals that can take us from i to j.\\nReturn true if it is possible to traverse between all such pairs of indices, or false otherwise.\\n \\nExample 1:\\n\\nInput: nums = [2,3,6]\\nOutput: true\\nExplanation: In this example, there are 3 possible pairs of indices: (0, 1), (0, 2), and (1, 2).\\nTo go from index 0 to index 1, we can use the sequence of traversals 0 -> 2 -> 1, where we move from index 0 to index 2 because gcd(nums[0], nums[2]) = gcd(2, 6) = 2 > 1, and then move from index 2 to index 1 because gcd(nums[2], nums[1]) = gcd(6, 3) = 3 > 1.\\nTo go from index 0 to index 2, we can just go directly because gcd(nums[0], nums[2]) = gcd(2, 6) = 2 > 1. Likewise, to go from index 1 to index 2, we can just go directly because gcd(nums[1], nums[2]) = gcd(3, 6) = 3 > 1.\\n\\nExample 2:\\n\\nInput: nums = [3,9,5]\\nOutput: false\\nExplanation: No sequence of traversals can take us from index 0 to index 2 in this example. So, we return false.\\n\\nExample 3:\\n\\nInput: nums = [4,3,12,8]\\nOutput: true\\nExplanation: There are 6 possible pairs of indices to traverse between: (0, 1), (0, 2), (0, 3), (1, 2), (1, 3), and (2, 3). A valid sequence of traversals exists for each pair, so we return true.\\n\\n \\nConstraints:\\n\\n1 <= nums.length <= 10^5\\n1 <= nums[i] <= 10^5\",\"question_title\":\"greatest-common-divisor-traversal\",\"starter_code\":\"class Solution:\\n    def canTraverseAllPairs(self, nums: List[int]) -> bool:\\n        \"}","display_format":"text","language":"","answer_status":"published","assets":[],"source_url":"https://livecodebench.github.io/","history":"initial import","indexing_mode":"noindex","subproblems":[],"grids":[]}