上一页 1 2 3 4 5 6 7 8 9 ··· 17 下一页
摘要: DFS。 #include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; vector<vector<int>> vec; int vis[10003]; int main() { int n,m,k; cin>>n 阅读全文
posted @ 2024-04-07 20:31 YuKiCheng 阅读(15) 评论(0) 推荐(0)
摘要: 拿起题就开始写,最后提交测试点2和测试点3就是过不去。 感觉一点问题都没有,好郁闷,找了半天,发现地点的编号是0开始的,而我一直在从1遍历.... 思路就是两个dijkstra,这两次思路是完全一样的,只是一个是最短距离最少节点,一个是最短时间最短距离,所以分别需要增加一个累计经过节点数量和累计节点 阅读全文
posted @ 2024-04-03 17:44 YuKiCheng 阅读(35) 评论(0) 推荐(0)
摘要: dijkstra。 #include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int distances[1010][1010]; int dis[1020],visited[1020]; int edges[ 阅读全文
posted @ 2024-04-03 12:16 YuKiCheng 阅读(18) 评论(0) 推荐(0)
摘要: 首先,这是一个三维空间上的,题目的意思就是给了五个3*4的切片,从下往上叠在一起,对于一个像素点来说,他的前后左右上下这六个方向都是他的连通像素点。 代码: #include <bits/stdc++.h> using namespace std; int a[65][130][1300]; int 阅读全文
posted @ 2024-04-03 10:41 YuKiCheng 阅读(16) 评论(0) 推荐(0)
摘要: 并查集的应用,我感觉这题不是很容易想出来。然后....代码看注释吧。 写法一, #include <bits/stdc++.h> using namespace std; int a[1010][1010],fa[1010]; int getf(int x){ while(fa[x]!=-1){ x 阅读全文
posted @ 2024-04-03 08:54 YuKiCheng 阅读(20) 评论(0) 推荐(0)
摘要: 维护两个栈。一个正常放数据,另一个是排序好的数据。 #include <bits/stdc++.h> using namespace std; int main(){ vector<int> data; vector<int> mdata; vector<int>::iterator it; int 阅读全文
posted @ 2024-04-02 20:01 YuKiCheng 阅读(24) 评论(0) 推荐(0)
摘要: 一道很简单的DFS。 #include <bits/stdc++.h> using namespace std; int n,m,a[10010]; vector<int> res; void dfs(int start,int own){ for(int i=start;i<n;i++){ if( 阅读全文
posted @ 2024-04-02 19:24 YuKiCheng 阅读(14) 评论(0) 推荐(0)
摘要: int类型最多表示的21亿,这个题int就可以。 #include <bits/stdc++.h> using namespace std; int getSum(int a){ int res = 0; while(a){ res += a%10; a/=10; } return res; } i 阅读全文
posted @ 2024-04-02 10:18 YuKiCheng 阅读(63) 评论(0) 推荐(0)
摘要: 暴力枚举。 #include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int res1,res2; int main(){ int a,b,c;//女生 男生 寝室数 cin>>a>>b>>c; int min 阅读全文
posted @ 2024-04-02 10:02 YuKiCheng 阅读(88) 评论(0) 推荐(0)
摘要: 这个题目是stl的使用和字符串拼接。 java里头substring是从首部到尾部的位置,但是C++里面substr是首部位置,和要截取的长度。 我算这种经常出错,每次都搞得很晕。 #include <bits/stdc++.h> using namespace std; string cs; in 阅读全文
posted @ 2024-04-02 08:52 YuKiCheng 阅读(109) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 17 下一页