摘要: 1.stringstream类 //基本操作 stringstream ss; ss.str("abc");//定义 ss.str("123");//修改 cout<<ss.str()<<'\n';//查看 ss.str("");//清空 ss<<s;//输入流 ss>>s;//输出流 //用途1: 阅读全文
posted @ 2026-06-03 22:58 spark_of_fire 阅读(1) 评论(0) 推荐(0)
摘要: 1.vscode在wsl切换回windows时由于wsl新配置文件的生成导致切回后c++无法运行,这时删掉wsl配置文件即可(删掉后再切回wsl也没关系,此文件会重新生成) 2.主函数带参数的代码文件直接运行是没反应的,应该在终端中编译出可执行文件再运行。 编译: g++ pms.cpp -O3 - 阅读全文
posted @ 2026-06-02 22:26 spark_of_fire 阅读(2) 评论(0) 推荐(0)
摘要: ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); cin cout解锁使用时,不能与 scanf,getchar, printf,cin.getline()混用。 阅读全文
posted @ 2026-02-25 23:59 spark_of_fire 阅读(7) 评论(0) 推荐(0)
摘要: 1.vector(向量) vector<int>(n); vector<vector<int>> a(n,vector<int>(n) );//n行n列 vector<vector<int>> a(n,vector<int>() );//n行,不指定列数 大小:int n=v.size(); 尾部加 阅读全文
posted @ 2026-02-25 23:55 spark_of_fire 阅读(6) 评论(0) 推荐(0)
摘要: 点击查看代码 #include<bits/stdc++.h> using namespace std; int main() { string a; cin>>a; string b; stack<char>st; for(int i=0;i<a.size();i++){ if(a[i]>='0'& 阅读全文
posted @ 2026-02-24 23:28 spark_of_fire 阅读(5) 评论(0) 推荐(0)
摘要: 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 阅读(5) 评论(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 阅读(5) 评论(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 阅读(5) 评论(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 阅读(5) 评论(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 阅读(7) 评论(0) 推荐(0)