摘要: #include <bits/stdc++.h> #define debug1(a) cout << #a << '=' << a << endl; #define debug2(a, b) cout << #a << " = " << a << " " << #b << " = " << b << 阅读全文
posted @ 2023-03-09 11:20 俄罗斯刺沙蓬 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 题目 https://leetcode.cn/problems/number-of-ways-to-earn-points/description/?orderBy=most_votes https://codeforces.com/problemset/problem/148/E 题意(仅第二题) 阅读全文
posted @ 2023-03-07 20:54 俄罗斯刺沙蓬 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 题目 https://codeforces.com/problemset/problem/219/D https://leetcode.cn/problems/count-number-of-possible-root-nodes/ https://leetcode.cn/problems/mini 阅读全文
posted @ 2023-03-06 15:47 俄罗斯刺沙蓬 阅读(36) 评论(0) 推荐(0) 编辑
摘要: ## 题目 - https://leetcode.cn/problems/triples-with-bitwise-and-equal-to-zero/description/?orderBy=most_votes ## 思路 - *[参考灵神题解,非常易懂,总结一些方法](https://leet 阅读全文
posted @ 2023-03-04 10:34 俄罗斯刺沙蓬 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 题目 https://codeforces.com/problemset/problem/1554/C 题意 输入 t(≤3e4) 表示 t 组数据,每组数据输入两个整数 n 和 m,均在 [0,1e9] 范围内。 定义数组 a = [n xor 0, n xor 1, n xor 2, ..., 阅读全文
posted @ 2023-03-02 15:41 俄罗斯刺沙蓬 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 题目 https://leetcode.cn/problems/handling-sum-queries-after-update/description/ 思路 操作2和操作3都非常好实现,直接累加一个和就行 关键在于操作1(nums1数组所有元素大小在0~1之间)翻转 线段树相比树状数组更好理解 阅读全文
posted @ 2023-02-26 21:22 俄罗斯刺沙蓬 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 题目 https://leetcode.cn/problems/minimum-time-to-visit-a-cell-in-a-grid/description/ 思路 首先,这是一个最短路问题 直接用朴素记忆化搜索或者bfs无法实现“反复横跳”这一功能(只有有两个点以上可以走,就可以走到任意一 阅读全文
posted @ 2023-02-26 19:51 俄罗斯刺沙蓬 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 题目 https://leetcode.cn/problems/count-the-number-of-square-free-subsets/ 思路 类似01背包优化的状态压缩dp(误) 首先按照数字分出是否有平方子集,然后再计数cnt[x] 枚举合法的数字(2 ~ 30),为什么不算1?因为所有 阅读全文
posted @ 2023-02-25 10:11 俄罗斯刺沙蓬 阅读(60) 评论(0) 推荐(0) 编辑
摘要: 题目 最长有效括号 方法一:dp int longestValidParentheses(string s) { int ans = 0; stack<int> sta; sta.push(-1); for(int i = 0;i < s.size();i ++) { if(s[i] == '(') 阅读全文
posted @ 2023-02-21 19:02 俄罗斯刺沙蓬 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 题目 Nearest Opposite Parity(多源最短路bfs) 题意 思路 多源最短路 代码 const int N = 2e5+10; int a[N]; vector<int> edge[N]; int dist[N]; int ans[N]; void bfs(vector<int> 阅读全文
posted @ 2023-02-19 15:45 俄罗斯刺沙蓬 阅读(14) 评论(0) 推荐(0) 编辑
返回顶端