Re: [閒聊] 每日leetcode

作者: sixB (6B)   2025-09-29 02:39:41
已經沒有人寫了嗎
2197.
不知道幾個禮拜前的
寫錯好幾版還有MLE
終於改出來惹
2289ms 我真的好爛
醜醜ㄉ:(
class Solution {
public:
vector<int> replaceNonCoprimes(vector<int>& nums) {
vector<int> res;
int n = nums.size();
bool left = false;
bitset<100001> b1;
unordered_map<int, int> p1;
get_bp(nums[0], b1, p1);
for(int i = 1; i < n; i++){
bitset<100001> b2;
unordered_map<int, int> p2;
get_bp(nums[i], b2, p2);
if((b1 & b2).any()){
b1 |= b2;
comb_p(p1, p2);
left = true;
}
else if(left){
int rlen = res.size();
for(int j = rlen-1; j >= 0; j
作者: DJYOMIYAHINA (通通打死)   2025-09-29 09:38:00
我好爛

Links booklink

Contact Us: admin [ a t ] ucptt.com