文章分类 - coding
算法竞赛
摘要:子集 II 因为元素可能会重复,且要求输出的组合不能重复,所以不能像子集再使用二进制方式去枚举 class Solution { public: vector<vector<int>> ans; vector<int> path; vector<vector<int>> subsetsWithDup
阅读全文
摘要:63. 不同路径 II class Solution { public: int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) { int m = obstacleGrid.size(); int n = obstacleGr
阅读全文
摘要:61. 旋转链表 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(
阅读全文
摘要:L2-044 大众情人 #include <bits/stdc++.h> using namespace std; int n, k; vector<int> man, woman; int dis[510][510]; map<int, set<int>> mp; void find(){ for
阅读全文
摘要:L2-043 龙龙送外卖 #include <bits/stdc++.h> using namespace std; const int MAXN = 100010; int n, m; int p[MAXN], f[MAXN]; int maxv; //从u结点走,向根节点(已经经过的结点)走了d
阅读全文
摘要:L2-041 插松枝 // # 用队列来模拟传送带,用栈来模拟盒子。 #include <bits/stdc++.h> using namespace std; int n, m, k; stack<int> S; queue<int> Q; signed main(){ cin >> n >> m
阅读全文
摘要:L2-042 老板的作息表 #include <bits/stdc++.h> using namespace std; typedef pair<string, string> PII; set<PII> record; string st, ed; int main(){ cin >> st; w
阅读全文
摘要:link 此题有坑,需要找到病毒源头,0并不一定是 #include <bits/stdc++.h> using namespace std; const int MAXN = 100010; int h[MAXN], e[MAXN], ne[MAXN], idx; int st[MAXN], p[
阅读全文
摘要:link #include <bits/stdc++.h> using namespace std; const int MAXN = 100010; int a[MAXN], num[MAXN], yifu[MAXN]; int A, B; bool isprime(int n){ if(n ==
阅读全文
摘要:link #include <bits/stdc++.h> using namespace std; typedef pair<string, int> PII; map<string, PII> mp; const int MAXN = 100010; int n; string check(st
阅读全文
摘要:link #include <bits/stdc++.h> using namespace std; int post[40], dfs[40]; int n, cnt = 1; void backtracking(int index){ if(index > n) return; backtrac
阅读全文
摘要:link #include <bits/stdc++.h> using namespace std; const int MAXN = 1100; int n, m, k; int st[MAXN]; int main(){ cin >> n >> m >> k; while(k--){ int f
阅读全文
摘要:link #include <bits/stdc++.h> using namespace std; const int N = 10010; int n, m; vector<int> g[N]; int deg[N], backup[N]; void check(){ for(int i = 1
阅读全文
摘要:link #include <bits/stdc++.h> using namespace std; const int MAXN = 510; int g[MAXN][MAXN]; int color[MAXN]; int n, m, k; int num; bool check(int i){
阅读全文
摘要:link #include <bits/stdc++.h> using namespace std; const int MAXN = 100010; struct Node{ int begin, val, next; }node[MAXN]; int nbegin, n; vector<Node
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; const int MAXN = 200010; int n; int dis[MAXN]; bool exist[MAXN]; struct Person{ int fid, mid; char sex;
阅读全文
摘要:link 必须要车号⼤的先出,⼩的后出。所以列车排队的每⼀队必须是从⼤到⼩排列(从右往左看),才能保证开出去的车也是从⼤到⼩的。对于每⼀个想要进⼊并列铁轨的车,如果车号⼤于每⼀队的队尾的车号,说明不能进⼊已经有的队伍,必须进⼊新的铁轨,否则,选择⼀个最接近它车号的尾部车号的队伍进⼊。其实⽆需保存每⼀
阅读全文
摘要:link #include <bits/stdc++.h> using namespace std; const int N = 1010; int n, T, D, E; vector<int> q[N]; bool st[N]; // 剩余数 = 总数 - 掉落数 - 疏果数 int get(v
阅读全文
摘要:link 将用操作和还操作分开进行排序 #include <bits/stdc++.h> using namespace std; const int N = 1010; int n, m, k; int a[N]; struct People{ int st, id, type; bool ope
阅读全文
摘要:link 方法一:模拟降落过程 #include <bits/stdc++.h> using namespace std; typedef pair<int, int> PII; int a[20][20], b[10][10]; bool st[20][20]; vector<PII> c, re
阅读全文