当前位置:网站首页>[错题]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,即从数字整体的角度做思考,而不能在当个数字中的每个字符上找局部的规律。
即需要有整体的思维。
边栏推荐
- 每周推荐短视频:如何正确理解“精益”这个词?
- STM32 RT-Thread虚拟文件系统挂载操作
- 收藏|0 基础开源数据可视化平台 FlyFish 大屏开发指南
- 20220726 at command test of Bluetooth module hc-05 of Huicheng Technology
- ES6 从入门到精通 # 08:扩展的对象的功能
- SSM integration (integrated configuration)
- MySQL stored procedures use cursors to synchronize data between two tables
- VMware virtual machine network settings
- 响应式高端网站模板源码图库素材资源下载平台源码
- 动态内存管理中的malloc、free、calloc、realloc动态内存开辟函数
猜你喜欢

53. Maximum subarray maximum subarray sum

VMware virtual machine network settings

Qt:QMessageBox消息框、自定义信号和槽

Unity简单实现对话功能

「运维有小邓」网络设备监控

4天Excel实战训练营,0.01元特惠仅三天,赠200套学习资料包

每周推荐短视频:如何正确理解“精益”这个词?

TypeError: ufunc ‘bitwise_and‘ not supported for the input types, and the inputs could not be safely

关于湖北文理学院平衡信标组的疑问回应

Integrate SSM to realize search of addition, deletion, modification and query
随机推荐
服务器内存故障预测居然可以这样做!
如何卸载干净zabbix服务?(超详细)
ASEMI整流桥GBPC3510在直流有刷电机中的妙用
Responsive high-end website template source code Gallery material resource download platform source code
Outlook 教程,如何在 Outlook 中使用颜色类别和提醒?
MSGAN用于多种图像合成的模式搜索生成对抗网络---解决模式崩塌问题
动态规划——474. 一和零
Xctf attack and defense world web master advanced area unserialize3
8000字讲透OBSA原理与应用实践
响应式高端网站模板源码图库素材资源下载平台源码
贪心——55. 跳跃游戏
MySQL stored procedures use cursors to synchronize data between two tables
Xctf attack and defense world web master advanced area php2
How does win11 display fixed applications?
20 soul chicken soup beautiful sentences, sentence by sentence warm heart!
Integrate SSM to realize search of addition, deletion, modification and query
Msgan is used for pattern search of multiple image synthesis to generate confrontation Network -- to solve the problem of pattern collapse
D2DEngine食用教程(4)———绘制文本
xctf攻防世界 Web高手进阶区 unserialize3
D2dengine edible tutorial (4) -- draw text