
本题思路:本题就是根据就是排序的知识点,在sort内部可以使用仿函数来改变此时排序规则。
- #include
-
- const int N=10010;
- int n;
- std::string logs[N];
-
- int main()
- {
- std::ios::sync_with_stdio(false);
- std::cin.tie(nullptr);std::cout.tie(nullptr);
-
- while(std::getline(std::cin,logs[n]))
- if(logs[n].size()) n++;
- else break;
- //内部排序
- sort(logs,logs+n,[&](std::string&a,std::string&b){
- std::stringstream sstreama(a),sstreamb(b);
-
- //将空格分开的字符串读入sa,sb中
- std::string sa[4],sb[4];
- for(int i=0;i<4;i++){
- sstreama>>sa[i];
- sstreamb>>sb[i];
- }
-
- //如果当前消耗时间相等,则需要判断当前开始时间
- if(sa[3]==sb[3]) return sa[1]+sa[2]
1]+sb[2]; -
- double ta,tb;
- std::sscanf(sa[3].c_str(),"%lf(s)",&ta);
- std::sscanf(sb[3].c_str(),"%lf(s)",&tb);
- return ta
- });
-
- for(int i=0;i
- return 0;
- }
二、重复者IO链接
本题思路:对于第q层来说我们需要递归找出第q-1层的图形然后将其存储下来然后和原来图形来更新第q层的图形。
- #include
-
- int n;
- std::vector
p; -
- std::vector
dfs(int k) - {
- if(k==1) return p;
-
- std::vector
last=dfs(k-1);//找出上一版本的字符串 - int m=last.size();
-
- std::vector
res(n*m,std::string(n*m,' ')) ;//当前版本串 -
- for(int i=0;i
- for(int j=0;j
- if(p[i][j]!=' ')
- for(int x=0;x
- for(int y=0;y
- res[i*m+x][j*m+y]=last[x][y];
-
- return res;
- }
-
- int main()
- {
- while(std::cin>>n,n){
- //清空当前的版本串
- p.clear();
- getchar();
-
- for(int i=0;i
- std::string s;
- std::getline(std::cin,s);
- p.push_back(s);
- }
-
- int q;
- std::cin>>q;
- auto res=dfs(q);
- for(auto& str:res)
- std::cout<
- }
- return 0;
- }
-
相关阅读:
中标麒麟 NeoKylin 5.1 安装C++环境
邮件钓鱼--有无SPF演示--Swaks
codeforces每日5题(均1700)-第二天
SpringCloud(一)--Eurea
生成器建造者模式(Builder)——创建型模式
【mindspore1.5.0】安装mindspore报libcuda.so没找到和libcudnn没找到
一篇文章带你掌握主流办公框架——SpringBoot
【计算机组成&体系结构】存储系统基本概念
spring-security源码学习总结
解读人工智能的理论基石
-
原文地址:https://blog.csdn.net/qq_67458830/article/details/132757534