- 博客(19)
- 收藏
- 关注
原创 团体程序设计天梯赛 L2-025 分而治之
并查集 先记录下每条路然后记录每个方案被攻打的城市如果这条路的双方都没被攻打就将他们连接#include<bits/stdc++.h>using namespace std;int vis[10006];void init(){ for(int i=1;i<=10005;i++){ vis[i]=0; }}int main(){ int n,m; cin>>n>>m; vector<pair<int,int> &g
2022-05-18 21:58:33
259
1
原创 L2-024 部落
并查集#include<bits/stdc++.h>using namespace std;int fa[10005];int n;void init(){ for(int i=1;i<=10004;i++) fa[i]=i;}int find(int x){ int k=x; while(x!=fa[x]) x=fa[x]; while(k!=x){ int l=fa[x]; fa[k]=x; k=l; } return x;}void.
2022-05-18 21:56:15
191
原创 团体程序设计天梯赛 L2-023 图着色问题
记录每个顶点后按给出的颜色一次次遍历看是否有重复值得注意的是要是使用到的颜色超过或者少于给的的颜色那么该方案也不行#include<bits/stdc++.h>using namespace std;int main(){ int v,e,k; cin>>v>>e>>k; vector<pair<int,int> >a; for(int i=0;i<e;i++){ int x,y; cin>&g
2022-05-18 21:55:08
165
原创 团体程序设计天梯赛 L2-019 悄悄关注
#include<bits/stdc++.h>using namespace std;bool cmp(string s,string k){ return s<k;}int main(){ map<string,int>mp; int n; cin>>n; for(int i=0;i<n;i++){ string s; cin>>s; mp[s]=1; } int k; cin>>k; vect.
2022-05-18 20:12:37
120
原创 团体程序设计天梯赛 L2-015 互评成绩
#include<bits/stdc++.h>using namespace std;bool cmp(double a,double b){ return a>b;}int main(){ int n,k,m; cin>>n>>k>>m; double su=0; double max=0,min=100; vector<double>a; for(int i=0;i<n;i++){ su=0; max.
2022-05-17 18:17:43
158
原创 团体程序设计天梯赛 L2-013 红色警报
失去本身就独立打城市对连通性并没有影响 因此可先判断该城市是否独立#include<bits/stdc++.h>using namespace std;int fa[500];int vis[501];int ff[501]={0};int lost[501]={0};int find(int x){ while(x!=fa[x]) x=fa[x]; return x;}void un(int x,int y){ int fx=find(x); int fy=f.
2022-05-17 18:17:13
252
原创 团体程序设计天梯赛 L2-010 排座位
并查集#include<bits/stdc++.h>using namespace std;int fa[500];int vis[501];int ff[501]={0};int lost[501]={0};int find(int x){ while(x!=fa[x]) x=fa[x]; return x;}void un(int x,int y){ int fx=find(x); int fy=find(y); fa[fx]=fy;} int
2022-05-17 18:15:50
101
原创 团体程序设计天梯赛 L2-009 抢红包
使用struct存储数据后使用sort函数排序#include<bits/stdc++.h>using namespace std;struct node{ int bh; double money=0; int gs=0;};bool cmp(struct node a,struct node b){ if(a.money!=b.money) return a.money>b.money; else if(a.gs!=b.gs) return a.gs>
2022-05-17 18:15:05
97
原创 团体程序设计天梯赛 L2-026 小字辈
不以祖先为跟节点 逆向建立树后使用dfs寻找最深的就可#include<bits/stdc++.h>using namespace std;set<int>bb[100001];vector<int>son[100001];int vis[100001]={0};int maxdeep=1;void dfs(int nowperson,int deep){ bb[deep].insert(nowperson); maxdeep=max(deep,m.
2022-05-15 23:22:31
139
原创 团体程序设计天梯赛 L2-031
使用dfs进行深度优先搜索一直走到不能走为止#include <bits/stdc++.h>using namespace std;vector<int>ma[100005];bool vis[100005]={0};int n;long long maxdeep=0;int door=0;void dfs(int start,int deep){ if(maxdeep<deep){ maxdeep=deep; door=start; } f.
2022-05-15 23:18:30
119
原创 团体程序设计天梯赛 L2-041 插松枝
理解题意就很好做#include<bits/stdc++.h>using namespace std;int main(){ int n,m,k; cin>>n>>m>>k; queue<int>tsq; stack<int>xhz; for(int i=0;i<n;i++){ int x; cin>>x; tsq.pus
2022-05-15 23:16:48
378
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅