摘要: 题目链接 题解1: 先排序,然后用自定义变量记录累计的score。 select gender,day,total from( select day, @s:=(if(gender=@g,@s+score_points,score_points)) as total, @g:=gender as g 阅读全文
posted @ 2020-02-06 18:04 feibilun 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题解: 先用所有的边生成一棵最小生成树,然后从后往前不断删边,看此边有没有用到,用到的话重新跑生成树,没有的话结果不变。还是Kruskal方便些。。。 Prime: #include <bits/stdc++.h> # define LL long long using namespace 阅读全文
posted @ 2020-02-06 12:32 feibilun 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题解: 每一个子连通图,对它进行黑白染色,然后取两种染色中的最小值,然后最后汇总。 #include <bits/stdc++.h> # define LL long long using namespace std; const int maxn=10000+10; const int 阅读全文
posted @ 2020-02-05 17:34 feibilun 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题解: 方法1: 走一遍dfs/bfs得到u->v的路径。每一个m,保证走过得边>=此最小值。再走一遍m,看路径的最小值是否是提供的。 #include <bits/stdc++.h> # define LL long long using namespace std; int n; in 阅读全文
posted @ 2020-02-05 15:03 feibilun 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 题目链接 解法: 栈 1 #include <bits/stdc++.h> 2 # define LL long long 3 using namespace std; 4 5 const int mod=10007; 6 stack<char> ope; 7 stack<int> one; 8 s 阅读全文
posted @ 2020-02-04 15:08 feibilun 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 题目链接 1 #include <bits/stdc++.h> 2 # define LL long long 3 using namespace std; 4 5 const int maxn=5000+10; 6 int n; 7 LL dis[maxn]; 8 int complete[max 阅读全文
posted @ 2020-02-04 09:13 feibilun 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目描述 输入k及k个整数n1,n2,…,nk,表示有k堆火柴棒,第i堆火柴棒的根数为ni;接着便是你和计算机取火柴棒的对弈游戏。取的规则如下:每次可以从一堆中取走若干根火柴,也可以一堆全部取走,但不允许跨堆取,也不允许不取。 谁取走最后一根火柴为胜利者。 编一个程序,在给出初始状态之后, 阅读全文
posted @ 2020-02-03 17:33 feibilun 阅读(204) 评论(0) 推荐(0) 编辑
摘要: Link Solution: O(n2): 1 #include <bits/stdc++.h> 2 # define LL long long 3 using namespace std; 4 const int INF=0x7fffffff; 5 int n, m, k; 6 int arr[3 阅读全文
posted @ 2020-02-03 11:30 feibilun 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 题目链接 1 #include <bits/stdc++.h> 2 # define LL long long 3 using namespace std; 4 5 bool dfs(vector<int> &num, vector<string> &res){ 6 if(num.size()==1 阅读全文
posted @ 2020-02-02 20:51 feibilun 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题解: 我们可以对棋盘进行黑白染色,使得任意相邻的两个格子颜色不相同,然后进行二分图最大匹配。 Code: 1 class Solution { 2 public: 3 int N; 4 int M; 5 6 vector<vector<int>> dir{{1,0},{0,1},{-1, 阅读全文
posted @ 2020-02-02 09:41 feibilun 阅读(205) 评论(0) 推荐(0) 编辑