上一页 1 ··· 8 9 10 11 12 13 14 15 下一页
摘要: P1546 [USACO3.1]最短网络 Agri-Net 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=105; 4 int n,tot; 5 int fa[N]; 6 int read() 7 { 8 int x=0 阅读全文
posted @ 2021-12-18 16:08 matt-11 阅读(45) 评论(0) 推荐(0)
摘要: 题目后续补吧,主要解决问题; 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1e5+5; 4 int fa[N]; 5 int find_fa(int x){ 6 return fa[x]=(x==fa[x])?x:fi 阅读全文
posted @ 2021-12-18 11:54 matt-11 阅读(27) 评论(0) 推荐(0)
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1e2+5; 4 int G[N][N]; 5 int main() 6 { 7 int n,m; 8 scanf("%d%d",&n,&m); 9 for(int i=1; 阅读全文
posted @ 2021-12-18 11:18 matt-11 阅读(31) 评论(0) 推荐(0)
摘要: 1610. 可见点的最大数目 1 class Solution { 2 public: 3 const double pi=M_PI; 4 double get_angel(int x1,int y1,int x2,int y2) 5 { 6 return atan(1.0*(y2-y1)/(x2- 阅读全文
posted @ 2021-12-17 14:25 matt-11 阅读(36) 评论(0) 推荐(0)
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef pair<int,double>pii; 4 const int N=2005; 5 const double inf=1e-5; 6 int n,m,st,ed; 7 double 阅读全文
posted @ 2021-12-16 23:06 matt-11 阅读(82) 评论(0) 推荐(0)
摘要: 题目要求的是两个牧场的最小直径,数据给出不只是两个独立牧场而是至少两个 所以我们要去暴力枚举每个不属于同一牧场的直径的最小值 这里需要注意的是两个牧场连起来的直径不一定是连线后 i所在的最短路+j所在的最短路+dis(i,j); 例如 1 #include<bits/stdc++.h> 2 usin 阅读全文
posted @ 2021-12-16 12:36 matt-11 阅读(47) 评论(0) 推荐(0)
摘要: //这是一道一笔画问题 算法名字叫Hierholzer 算法 算法介绍传送门https://www.cnblogs.com/acxblog/p/7390301.html 1 class Solution { 2 public: 3 vector<vector<int>> validArrangeme 阅读全文
posted @ 2021-12-15 17:54 matt-11 阅读(29) 评论(0) 推荐(0)
摘要: 630. 课程表 III 这题的思路是贪心; 首先对于一个课程,[d1,ed1],[d2,ed2];如果都能满足要求,我们优先选择ed小的;这里假设ed1<ed2; 证明:如果ed2选上能获得最优解,那么ed2的课程换成ed1一定不比最优解差,所以按照结束时间ed排序; 问题在于当dx+time>e 阅读全文
posted @ 2021-12-14 16:56 matt-11 阅读(48) 评论(0) 推荐(0)
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 int len; 4 int myheap[12]; 5 //堆排序每个子节点最多交换log次,所以堆排是nlogn; 6 void put(int x) 7 { 8 myheap[++len]=x 阅读全文
posted @ 2021-12-13 22:45 matt-11 阅读(34) 评论(0) 推荐(0)
摘要: 2106. 摘水果 1 const int N=2e6; 2 int lt[N],rt[N]; 3 class Solution { 4 public: 5 int maxTotalFruits(vector<vector<int>>& fruits, int startPos, int k) { 阅读全文
posted @ 2021-12-13 21:23 matt-11 阅读(101) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 下一页