当前位置:网站首页>Preparation for the computer test of Baosteel 15: a master of string processing
Preparation for the computer test of Baosteel 15: a master of string processing
2022-07-18 14:53:00 【Alkali!】
Title Description
https://www.acwing.com/problem/content/3409/
Ideas
There is no algorithm content in this problem , The main Look at grammar
This is a multi-dimensional sorting problem
Code
#include<iostream>
#include<cstring>
#include<algorithm>
#include<sstream>
using namespace std;
const int N=10010;
string logs[N];
int n;
int main()
{
while(getline(cin,logs[n]))
{
if(logs[n].size()) n++;
else break;
}
// Sort , I have to write the sorting by myself cmp Comparison function
sort(logs,logs+n,[](string& a,string& b){
stringstream ssina(a),ssinb(b);
string sa[4],sb[4];
for(int i=0;i<4;i++)
// utilize stringstream Divide the string into spaces
{
ssina>>sa[i];
ssinb>>sb[i];
}
// If two computing tasks consume the same time , Then the computing tasks that started earlier will be ranked first . Because the length is fixed , The length of the two compared parts is the same , Therefore, the dictionary order can be directly compared here
if(sa[3]==sb[3]) return sa[1]+sa[2]<sb[1]+sb[2];
double da,db;
// The numbers are different , utilize sscanf Extract floating point number , Let's make another comparison
// because sscanf yes C Library function , I won't support it string, All have to pass first .c_str() Convert to character array
sscanf(sa[3].c_str(),"%lf(s)",&da);
sscanf(sb[3].c_str(),"%lf(s)",&db);
return da<db;
});
// Output
for(int i=0;i<n;i++)
cout<<logs[i]<<endl;
return 0;
}
边栏推荐
- 数百亿数据压缩至 600GB,TDengine 落地协鑫能科移动能源平台
- Configure maskrcnn environment roast (geforce mx250+win10+tensorflow1.5.0 GPU version)
- Ask about the parallelism of MySQL source. The downstream parallelism of my source is 1. If I find that I can't turn on parallelism, I'll talk to you
- Remove the problem of repeated letters (the minimum sequence of different characters)
- 小程序毕设作品之微信评选投票小程序毕业设计(8)毕业设计论文模板
- Desai wisdom number - histogram (positive and negative bar graph): expectation & actual salary of 2022 graduates in different cities
- vivado里那些看不懂的约束语句
- Variables in shell scripts
- Reconstructing the geometric form of weight space with training set
- angr原理与实践(一)——原理
猜你喜欢
![NC16857 [NOI1999]生日蛋糕](/img/40/95b3a62c829f352bd8e85943d01c5c.png)
NC16857 [NOI1999]生日蛋糕

Ziguang Tongchuang FPGA development jump pit Guide (V) -- DDR3 controller IP simulation

HMM & MEMM & CRF

风控人不能不知的黑产大揭秘

About mock third-party calls

06-GuliMall 基础CRUD功能创建

Going to sea has become a general trend. How can technology be empowered| ArchSummit

Eureka中读写锁的奇思妙想,太顶了!

HAL 固件库

去除重复字母(不同字符的最小序列)问题
随机推荐
数据敏捷,HTAP数据库既决效率又决生死
Learning experience sharing 6: experience sharing of Dr. dry goods
AcWing 3540. 二叉搜索树 二叉排序树 BST
小程序毕设作品之微信评选投票小程序毕业设计(6)开题答辩PPT
Three cycle structure of Microcomputer Principle and technology interface experiment
Writing a new app with swift5 requires some considerations
博云入选 Gartner 中国云管理工具市场指南代表厂商
WWDC22 - Apple 隐私技术探索
Tens of billions of data were compressed to 600gb, and tdengine was launched on GCL energy mobile energy platform
STM32应用开发实践教程:基于 RS-485 总线的多机通信应用开发
HMM & MEMM & CRF
Gee (6): set the number of decimal places reserved for the calculated value / image
antd a-upload 多选multiple为ture时 限制上传个数
What if the self incrementing ID of online MySQL is exhausted?
Xsslabs customs clearance
How to write ADB SQL in dataworks
7-redis architecture design to use scenarios - cache penetration, cache avalanche, cache preheating, cache degradation
AcWing 3619. 日期 日期处理
后台运行程序方法
Data agility, HTAP database determines both efficiency and life and death