摘要: 1. 模板题:多余的边 思路:n条边n个点。类似于克鲁斯卡尔,加边的同时用并查集判断边的两端点是否同根,若同根,则要删除该边。 点击查看代码 #include<bits/stdc++.h> using namespace std; const int N=2000; int main() { int 阅读全文
posted @ 2026-01-23 21:17 spark_of_fire 阅读(3) 评论(0) 推荐(0)
摘要: dijkstra(堆优化版):参加大会 点击查看代码 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; #define inf 0x3f3f3f3f//1e9级别且2倍仍在int范围内 typedef pair<int, 阅读全文
posted @ 2026-01-23 18:37 spark_of_fire 阅读(3) 评论(0) 推荐(0)
摘要: 模板题:软件构建 点击查看代码 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; vector<int> v[N]; int main() { int n,m; cin>>n>>m; vector<int>in(n); 阅读全文
posted @ 2026-01-23 18:01 spark_of_fire 阅读(3) 评论(0) 推荐(0)
摘要: 模板题:寻宝 1.克鲁斯卡尔(并查集) 点击查看代码 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; typedef struct{ int w,a,b; }edge; edge e[N]; bool cmp(edge 阅读全文
posted @ 2026-01-23 17:59 spark_of_fire 阅读(2) 评论(0) 推荐(0)
摘要: 关于二维vector: vector<vector> a(n,vector(n) );//n行n列(n为输入变量) vector<vector> a(n,vector() );//n行,不指定列数 但是数组不支持变长: const int N=n; int a[N][N];//错误 const in 阅读全文
posted @ 2026-01-01 23:56 spark_of_fire 阅读(5) 评论(0) 推荐(0)
摘要: 链表题注意项: 1.适时用虚拟头结点会更方便dummyhead 2.注意对空指针的讨论,对空指针是无法访问val或者next的 内存分配与内存释放: //c++ ListNode* dummyHead = new ListNode; ListNode* dummyHead = new ListNod 阅读全文
posted @ 2026-01-01 22:46 spark_of_fire 阅读(3) 评论(0) 推荐(0)