1.相邻数对
#include #include #include #include using namespace std; #define N 1010 int a[N]; int main(){ int n; cin>>n; for(int i=0;i>a[i]; sort(a,a+n); long long ans=0; for(int i=0;i 2.画图 直接模拟即可: #include #include #include #include using namespace std; #define N 102 int a[N][N]={0}; void mm(int x1,int y1,int x2,int y2){ for(int i=x1;i>n; while(n--){ int x1,x2,y1,y2; cin>>x1>>y1>>x2>>y2; mm(x1,y1,x2,y2); } int ans=0; for(int i=0;i<=100;i++) for(int j=0;j<=100;j++) ans+=a[i][j]; cout< 3.字符串匹配 #include using namespace std; void lower(string &s){ for(int i=0;i='A'&&s[i]<='Z') s[i]=s[i]-'A'+'a'; } int main(){ string h; cin>>h; int op,n; cin>>op>>n; if(!op) lower(h); for(int i=0;i>st; s=st; if(!op) lower(s); if(s.find(h)!=-1) cout< 用strstr(父串,子串)可以更快的找到子字符串,时间复杂度为o(n),没有找到则返回NULL #include #include using namespace std; void lower(string &s){ for(int i=0;i='A'&&s[i]<='Z') s[i]=s[i]-'A'+'a'; } int main(){ string h; cin>>h; int op,n; cin>>op>>n; if(!op) lower(h); for(int i=0;i>st; s=st; if(!op) lower(s); if(strstr(s.c_str(),h.c_str())!=NULL) cout< 4.最优配餐 自己的代码,可以通过CSP官网,不能通过ACWing(超时 #include #include #include using namespace std; // 首先从栋栋的所有起点开始多源bfs,得到起点到一整张图的距离 // 枚举客户即可 struct node{ int x,y,c; }; int n,m,k,d; #define N 1010 int mp[N][N]; int dir[4][2]={0,1,0,-1,-1,0,1,0}; int main(){ memset(mp,-1,sizeof(mp)); cin>>n>>m>>k>>d; queue q; vector user; while(m--){ int x,y; cin>>x>>y; q.push((node){x,y,0}); } while(k--){ int x,y,c; cin>>x>>y>>c; user.push_back((node){x,y,c}); } while(d--){ int x,y; cin>>x>>y; mp[x][y]=0; } while(q.size()){ node top=q.front(); q.pop(); if(top.x<=0||top.x>n||top.y<=0||top.y>n||mp[top.x][top.y]!=-1) continue; mp[top.x][top.y]=top.c++; for(int i=0;i<4;i++) q.push((node){top.x+dir[i][0],top.y+dir[i][1],top.c}); } long long ans=0; for(int i=0;i y总的代码:(明天再整理吧
2.画图 直接模拟即可:
#include #include #include #include using namespace std; #define N 102 int a[N][N]={0}; void mm(int x1,int y1,int x2,int y2){ for(int i=x1;i>n; while(n--){ int x1,x2,y1,y2; cin>>x1>>y1>>x2>>y2; mm(x1,y1,x2,y2); } int ans=0; for(int i=0;i<=100;i++) for(int j=0;j<=100;j++) ans+=a[i][j]; cout< 3.字符串匹配 #include using namespace std; void lower(string &s){ for(int i=0;i='A'&&s[i]<='Z') s[i]=s[i]-'A'+'a'; } int main(){ string h; cin>>h; int op,n; cin>>op>>n; if(!op) lower(h); for(int i=0;i>st; s=st; if(!op) lower(s); if(s.find(h)!=-1) cout< 用strstr(父串,子串)可以更快的找到子字符串,时间复杂度为o(n),没有找到则返回NULL #include #include using namespace std; void lower(string &s){ for(int i=0;i='A'&&s[i]<='Z') s[i]=s[i]-'A'+'a'; } int main(){ string h; cin>>h; int op,n; cin>>op>>n; if(!op) lower(h); for(int i=0;i>st; s=st; if(!op) lower(s); if(strstr(s.c_str(),h.c_str())!=NULL) cout< 4.最优配餐 自己的代码,可以通过CSP官网,不能通过ACWing(超时 #include #include #include using namespace std; // 首先从栋栋的所有起点开始多源bfs,得到起点到一整张图的距离 // 枚举客户即可 struct node{ int x,y,c; }; int n,m,k,d; #define N 1010 int mp[N][N]; int dir[4][2]={0,1,0,-1,-1,0,1,0}; int main(){ memset(mp,-1,sizeof(mp)); cin>>n>>m>>k>>d; queue q; vector user; while(m--){ int x,y; cin>>x>>y; q.push((node){x,y,0}); } while(k--){ int x,y,c; cin>>x>>y>>c; user.push_back((node){x,y,c}); } while(d--){ int x,y; cin>>x>>y; mp[x][y]=0; } while(q.size()){ node top=q.front(); q.pop(); if(top.x<=0||top.x>n||top.y<=0||top.y>n||mp[top.x][top.y]!=-1) continue; mp[top.x][top.y]=top.c++; for(int i=0;i<4;i++) q.push((node){top.x+dir[i][0],top.y+dir[i][1],top.c}); } long long ans=0; for(int i=0;i y总的代码:(明天再整理吧
3.字符串匹配
#include using namespace std; void lower(string &s){ for(int i=0;i='A'&&s[i]<='Z') s[i]=s[i]-'A'+'a'; } int main(){ string h; cin>>h; int op,n; cin>>op>>n; if(!op) lower(h); for(int i=0;i>st; s=st; if(!op) lower(s); if(s.find(h)!=-1) cout< 用strstr(父串,子串)可以更快的找到子字符串,时间复杂度为o(n),没有找到则返回NULL #include #include using namespace std; void lower(string &s){ for(int i=0;i='A'&&s[i]<='Z') s[i]=s[i]-'A'+'a'; } int main(){ string h; cin>>h; int op,n; cin>>op>>n; if(!op) lower(h); for(int i=0;i>st; s=st; if(!op) lower(s); if(strstr(s.c_str(),h.c_str())!=NULL) cout< 4.最优配餐 自己的代码,可以通过CSP官网,不能通过ACWing(超时 #include #include #include using namespace std; // 首先从栋栋的所有起点开始多源bfs,得到起点到一整张图的距离 // 枚举客户即可 struct node{ int x,y,c; }; int n,m,k,d; #define N 1010 int mp[N][N]; int dir[4][2]={0,1,0,-1,-1,0,1,0}; int main(){ memset(mp,-1,sizeof(mp)); cin>>n>>m>>k>>d; queue q; vector user; while(m--){ int x,y; cin>>x>>y; q.push((node){x,y,0}); } while(k--){ int x,y,c; cin>>x>>y>>c; user.push_back((node){x,y,c}); } while(d--){ int x,y; cin>>x>>y; mp[x][y]=0; } while(q.size()){ node top=q.front(); q.pop(); if(top.x<=0||top.x>n||top.y<=0||top.y>n||mp[top.x][top.y]!=-1) continue; mp[top.x][top.y]=top.c++; for(int i=0;i<4;i++) q.push((node){top.x+dir[i][0],top.y+dir[i][1],top.c}); } long long ans=0; for(int i=0;i y总的代码:(明天再整理吧
用strstr(父串,子串)可以更快的找到子字符串,时间复杂度为o(n),没有找到则返回NULL
#include #include using namespace std; void lower(string &s){ for(int i=0;i='A'&&s[i]<='Z') s[i]=s[i]-'A'+'a'; } int main(){ string h; cin>>h; int op,n; cin>>op>>n; if(!op) lower(h); for(int i=0;i>st; s=st; if(!op) lower(s); if(strstr(s.c_str(),h.c_str())!=NULL) cout< 4.最优配餐 自己的代码,可以通过CSP官网,不能通过ACWing(超时 #include #include #include using namespace std; // 首先从栋栋的所有起点开始多源bfs,得到起点到一整张图的距离 // 枚举客户即可 struct node{ int x,y,c; }; int n,m,k,d; #define N 1010 int mp[N][N]; int dir[4][2]={0,1,0,-1,-1,0,1,0}; int main(){ memset(mp,-1,sizeof(mp)); cin>>n>>m>>k>>d; queue q; vector user; while(m--){ int x,y; cin>>x>>y; q.push((node){x,y,0}); } while(k--){ int x,y,c; cin>>x>>y>>c; user.push_back((node){x,y,c}); } while(d--){ int x,y; cin>>x>>y; mp[x][y]=0; } while(q.size()){ node top=q.front(); q.pop(); if(top.x<=0||top.x>n||top.y<=0||top.y>n||mp[top.x][top.y]!=-1) continue; mp[top.x][top.y]=top.c++; for(int i=0;i<4;i++) q.push((node){top.x+dir[i][0],top.y+dir[i][1],top.c}); } long long ans=0; for(int i=0;i y总的代码:(明天再整理吧
4.最优配餐 自己的代码,可以通过CSP官网,不能通过ACWing(超时
#include #include #include using namespace std; // 首先从栋栋的所有起点开始多源bfs,得到起点到一整张图的距离 // 枚举客户即可 struct node{ int x,y,c; }; int n,m,k,d; #define N 1010 int mp[N][N]; int dir[4][2]={0,1,0,-1,-1,0,1,0}; int main(){ memset(mp,-1,sizeof(mp)); cin>>n>>m>>k>>d; queue q; vector user; while(m--){ int x,y; cin>>x>>y; q.push((node){x,y,0}); } while(k--){ int x,y,c; cin>>x>>y>>c; user.push_back((node){x,y,c}); } while(d--){ int x,y; cin>>x>>y; mp[x][y]=0; } while(q.size()){ node top=q.front(); q.pop(); if(top.x<=0||top.x>n||top.y<=0||top.y>n||mp[top.x][top.y]!=-1) continue; mp[top.x][top.y]=top.c++; for(int i=0;i<4;i++) q.push((node){top.x+dir[i][0],top.y+dir[i][1],top.c}); } long long ans=0; for(int i=0;i y总的代码:(明天再整理吧
y总的代码:(明天再整理吧
上一篇 厚积薄发打卡Day86: Shiro+JWT+Redis实现微信小程序实现单点登录(下)<整合Shiro>
下一篇 docker数据卷
版权所有 (c)2021-2022 MSHXW.COM
ICP备案号:晋ICP备2021003244-6号