| 模型 | 模型答案 | 正确答案 |
|---|---|---|
| 金声玉亮2.0 | ```python class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 n = len(nums) for i in range(n): for j in range(i, n): x, y = nums[i], nums[j] if abs(x - y) <= min(x, y): max_xor = max(max_xor, x ^ y) return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| deepseek-r1 | ```python from typing import List class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 n = len(nums) for i in range(n): for j in range(n): x, y = nums[i], nums[j] if abs(x - y) <= min(x, y): current_xor = x ^ y if current_xor > max_xor: max_xor = current_xor return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| gpto1 | ```python class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 n = len(nums) for i in range(n): for j in range(n): x = nums[i] y = nums[j] if abs(x - y) <= min(x, y): xor_value = x ^ y if xor_value > max_xor: max_xor = xor_value return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| gpt-4o-2024-08-06 | ```python class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 n = len(nums) for i in range(n): for j in range(i, n): x, y = nums[i], nums[j] if abs(x - y) <= min(x, y): max_xor = max(max_xor, x ^ y) return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| DeepSeek-Coder-V2-Lite-Instruct | ```python from typing import List class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 for i in range(len(nums)): for j in range(len(nums)): if abs(nums[i] - nums[j]) <= min(nums[i], nums[j]): max_xor = max(max_xor, nums[i] ^ nums[j]) return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| Meta-Llama-3.1-405B-Instruct-Turbo | ```python from typing import List class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 for i in range(len(nums)): for j in range(i, len(nums)): if abs(nums[i] - nums[j]) <= min(nums[i], nums[j]): max_xor = max(max_xor, nums[i] ^ nums[j]) return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| Meta-Llama-3.1-70B-Instruct-Turbo | ```python class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 for i in range(len(nums)): for j in range(len(nums)): if abs(nums[i] - nums[j]) <= min(nums[i], nums[j]): max_xor = max(max_xor, nums[i] ^ nums[j]) return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| Qwen2-72B-Instruct | ```python class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: n = len(nums) nums.sort() max_xor = 0 for i in range(n): low, high = i, n-1 while low <= high: mid = (low + high) // 2 if nums[mid] <= 2*nums[i]: high = mid - 1 else: low = mid + 1 for j in range(i, min(high+2, n)): if abs(nums[i] - nums[j]) <= min(nums[i], nums[j]): max_xor = max(max_xor, nums[i] ^ nums[j]) return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| baichuan4 | ```python class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: # Sort the array to make sure we can easily find strong pairs nums.sort() max_xor = 0 # Iterate through the sorted array to find strong pairs for i in range(len(nums)): for j in range(i, len(nums)): # Check if the pair (nums[i], nums[j]) is a strong pair if abs(nums[i] - nums[j]) <= min(nums[i], nums[j]): # Calculate the XOR of the strong pair and update max_xor if necessary max_xor = max(max_xor, nums[i] ^ nums[j]) return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| doubao | ```python class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 for i in range(len(nums)): for j in range(len(nums)): if abs(nums[i] - nums[j]) <= min(nums[i], nums[j]): max_xor = max(max_xor, nums[i] ^ nums[j]) return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| gpto1 | ```python class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 n = len(nums) for i in range(n): for j in range(n): x = nums[i] y = nums[j] if abs(x - y) <= min(x, y): xor_value = x ^ y if xor_value > max_xor: max_xor = xor_value return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| kimi | ```python class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: n = len(nums) ans = 0 for i in range(n): for j in range(i, n): if abs(nums[i] - nums[j]) <= min(nums[i], nums[j]): ans = max(ans, nums[i] ^ nums[j]) return ans ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| minimax | ```python from typing import List class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: # Initialize the maximum XOR value to 0 max_xor = 0 # Iterate through all pairs of numbers in nums for i in range(len(nums)): for j in range(i, len(nums)): # Calculate the XOR of the current pair xor_value = nums[i] ^ nums[j] # Check if the current pair is a strong pair if abs(nums[i] - nums[j]) <= min(nums[i], nums[j]): # Update the maximum XOR value if the current XOR is greater max_xor = max(max_xor, xor_value) return max_xor # Example usage: # sol = Solution() # print(sol.maximumStrongPairXor([1,2,3,4,5])) # Output: 7 # print(sol.maximumStrongPairXor([10,100])) # Output: 0 # print(sol.maximumStrongPairXor([5,6,25,30])) # Output: 7 ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| wenxinyiyan | ```python from typing import List class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 n = len(nums) for i in range(n): for j in range(n): x = nums[i] y = nums[j] # Check if (x, y) forms a strong pair if abs(x - y) <= min(x, y): # Calculate XOR and update max_xor if necessary pair_xor = x ^ y max_xor = max(max_xor, pair_xor) return max_xor ``` This solution uses a nested loop to iterate through all possible pairs of integers in the `nums` list. For each pair, it checks if the pair forms a strong pair by verifying the condition `|x - y| <= min(x, y)`. If the pair is strong, it calculates the bitwise XOR of the two integers and updates `max_xor` if the current XOR value is greater than the previous maximum. Finally, it returns the maximum XOR value found. Note: Although this solution is correct, it has a time complexity of O(n^2) due to the nested loops. Given the small constraints of the problem (`nums.length <= 50`), this solution is acceptable. However, for larger inputs, a more efficient algorithm would be needed. |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| zhipu | ```python from typing import List class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 n = len(nums) for i in range(n): for j in range(n): x, y = nums[i], nums[j] if abs(x - y) <= min(x, y): max_xor = max(max_xor, x ^ y) return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |
| deepseek-v3 | ```python class Solution: def maximumStrongPairXor(self, nums: List[int]) -> int: max_xor = 0 n = len(nums) for i in range(n): for j in range(i, n): x = nums[i] y = nums[j] if abs(x - y) <= min(x, y): current_xor = x ^ y if current_xor > max_xor: max_xor = current_xor return max_xor ``` |
[{"input": "[1, 2, 3, 4, 5]", "output": "7", "testtype": "functional"}, {"input": "[10, 100]", "output": "0", "testtype": "functional"}, {"input": "[5, 6, 25, 30]", "output": "7", "testtype": "functional"}] |