当前位置:网站首页>[错题]Concatenation
[错题]Concatenation
2022-07-28 03:28:00 【wingaso】
#include<bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
int n;
string A[N];
bool cmp(const string &a,const string &b){
return a + b < b + a;
}
int main(){
cin >> n;
for(int i = 0;i < n;i++){
cin >> A[i];
}
sort(A,A + n,cmp);
for(auto it : A)
printf("%s",it.c_str());
return 0;
}
这一题官方解题思路是建立一颗trie,将时间复杂度降低至 O ( n ) O(n) O(n),但因为平台环境原因,可以通过卡常数,用 O ( l o g 2 n ) O(log_2n) O(log2n)的复杂度的代码通过。
对于这道题,比较两个数字前后关系,只需要 a + b < b + a a+b < b + a a+b<b+a,即从数字整体的角度做思考,而不能在当个数字中的每个字符上找局部的规律。
即需要有整体的思维。
边栏推荐
- Defect detection of BP SVM system design of leaf defect detection
- How to use JDBC to operate database
- golang 获取循环嵌套结构的tag
- Embedded database -- SQLite
- VMware虚拟机网络设置
- 超好看的Nteam官网PHP程序源码
- Super nice PHP program source code of nteam official website
- 8000字讲透OBSA原理与应用实践
- Outlook 教程,如何在 Outlook 中使用颜色类别和提醒?
- Container related concepts
猜你喜欢

How to uninstall clean ZABBIX service? (super detailed)

The open source of "avoiding disease and avoiding medicine" will not go far

动态内存管理中的malloc、free、calloc、realloc动态内存开辟函数

整合SSM实现增删改查搜索

How does win11 display fixed applications?

95后阿里P7晒出工资单:真的是狠狠扎心了...

Responsive high-end website template source code Gallery material resource download platform source code

ES6 从入门到精通 # 09:Symbol 类型

Color recognition method and exploration based on MATLAB

最新版宝塔安装zip扩展,php -m 不显示的处理方法
随机推荐
The wonderful use of asemi rectifier bridge GBPC3510 in DC brush motor
D2DEngine食用教程(4)———绘制文本
Redis基本操作
Container related concepts
动态规划——63. 不同路径 II
如何让外网访问内网IP(esp8266网页使用)
我的创作纪念日
20220726 at command test of Bluetooth module hc-05 of Huicheng Technology
20220727 use the Bluetooth module hc-05 of Huicheng technology to pair mobile phones for Bluetooth serial port demonstration
Leaf recognition, color feature extraction, defect detection, etc
input 上传文件并回显 FileReader并限制选择文件时的类型
「运维有小邓」网络设备监控
如何卸载干净zabbix服务?(超详细)
Response to questions about the balanced beacon group of Hubei University of Arts and Sciences
收藏|0 基础开源数据可视化平台 FlyFish 大屏开发指南
Malloc, free, calloc, realloc dynamic memory development functions in dynamic memory management
LabVIEW加载和使用树型控件项目中的定制符号
MySQL事务的ACID特性及并发问题实例分析
D2dengine edible tutorial (4) -- draw text
鼠标操作和响应