news 2026/6/11 15:21:53

代码随想录 打卡第五十三天

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
代码随想录 打卡第五十三天

卡码网 110 字符串迁移

#include <iostream> #include <vector> #include <string> #include <unordered_set> #include <unordered_map> #include <queue> using namespace std; int main() { string beginStr, endStr, str; int n; cin >> n; unordered_set<string> strSet; cin >> beginStr >> endStr; for (int i = 0; i < n; i++) { cin >> str; strSet.insert(str); } unordered_map<string, int> visitMap; queue<string> que; que.push(beginStr); visitMap.insert(pair<string, int>(beginStr, 1)); while(!que.empty()) { string word = que.front(); que.pop(); int path = visitMap[word]; for (int i = 0; i < word.size(); i++) { string newWord = word; for (int j = 0 ; j < 26; j++) { newWord[i] = j + 'a'; if (newWord == endStr) { cout << path + 1 << endl; return 0; } if (strSet.find(newWord) != strSet.end() && visitMap.find(newWord) == visitMap.end()) { visitMap.insert(pair<string, int>(newWord, path + 1)); que.push(newWord); } } } } cout << 0 << endl; }

卡码网 105 有向图的完全联通

#include<iostream> #include<list> #include<vector> using namespace std; void dfs(vector<list<int>>& graph,vector<int>& visit,int index){ if(visit[index] == 1) return; visit[index] = 1; list<int> nodes = graph[index]; for(int nextnode:nodes){ dfs(graph,visit,nextnode); } return; } int main(){ int n,m,x,y; cin >> n >> m; vector<list<int>> graph(n+1); while(m--){ cin >> x >> y; graph[x].push_back(y); } vector<int> visit(n+1,0); dfs(graph,visit,1); for(int i = 1;i < n+1;i++){ if(visit[i] == 0) { cout << -1; return 0; } } cout << 1; return 0; }

卡码网 106 海岸线计算

#include<iostream> #include<vector> using namespace std; int inorder[4][2] = {0,1, 1,0, 0,-1, -1,0}; int main(){ int n,m; cin >> n >> m; vector<vector<int>> graph(n,vector<int>(m,0)); for(int i = 0;i < n;i++){ for(int j = 0;j < m;j++){ cin >> graph[i][j]; } } int len = 0; for(int i = 0;i < n;i++){ for(int j = 0;j < m;j++){ if(graph[i][j] == 0) continue; for(int k = 0;k < 4;k++){ int next_x = i + inorder[k][0]; int next_y = j + inorder[k][1]; if(next_x < graph.size() && next_x >= 0 && next_y < graph[0].size() && next_y >= 0){ if(graph[next_x][next_y] == 0) len++; }else{ len++; } } } } cout << len; return 0; }
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/11 15:20:12

14亿美元押注“物理AI”:人形机器人的黄金时代真的来了吗?

2026年6月11日&#xff0c;德国人形机器人公司Neura Robotics宣布完成C轮融资&#xff0c;总额最高可达14亿美元。本轮融资阵容堪称豪华——稳定币发行商Tether、芯片巨头高通、科技巨头亚马逊和英伟达、欧洲工业巨头博世和舍弗勒、乃至欧洲投资银行悉数入列。公司估值约70亿美…

作者头像 李华
网站建设 2026/6/11 15:15:05

Revelation光影包:为Minecraft带来物理级真实渲染的创新解决方案

Revelation光影包&#xff1a;为Minecraft带来物理级真实渲染的创新解决方案 【免费下载链接】Revelation An explorative shaderpack for Minecraft: Java Edition 项目地址: https://gitcode.com/gh_mirrors/re/Revelation 在Minecraft的视觉体验演进中&#xff0c;玩…

作者头像 李华
网站建设 2026/6/11 15:12:57

深入解析PCA9673:I2C总线IO扩展器的硬件设计与软件驱动实战

1. 项目概述与核心价值在嵌入式系统开发中&#xff0c;我们经常会遇到一个经典难题&#xff1a;主控微控制器&#xff08;MCU&#xff09;的通用输入输出&#xff08;GPIO&#xff09;引脚不够用了。无论是连接矩阵键盘、驱动多位数码管、读取一排拨码开关的状态&#xff0c;还…

作者头像 李华
网站建设 2026/6/11 15:12:28

Pico VR开发即用包:Unity 5.6.1工程+手柄射线交互脚本(适配Neo/G2)

本文还有配套的精品资源&#xff0c;点击获取 简介&#xff1a;专为Pico Neo、Pico G2等早期一体机设备优化的Unity 5.6.1f1开发模板&#xff0c;开箱即可编译运行。项目已预设标准Assets目录结构&#xff0c;含Scenes、Scripts、Prefabs等常用文件夹&#xff0c;支持团队协…

作者头像 李华
网站建设 2026/6/11 15:12:13

终极指南:如何用Tabula快速免费地从PDF中解放表格数据

终极指南&#xff1a;如何用Tabula快速免费地从PDF中解放表格数据 【免费下载链接】tabula Tabula is a tool for liberating data tables trapped inside PDF files 项目地址: https://gitcode.com/gh_mirrors/ta/tabula 还在为从PDF文件中提取表格数据而烦恼吗&#x…

作者头像 李华