社区讨论
MLE 0pts求助
P1012[NOIP 1998 提高组] 拼数参与者 3已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @m274crmw
- 此快照首次捕获于
- 2024/10/13 13:02 去年
- 此快照最后确认于
- 2025/11/04 17:18 4 个月前
rt
Code:
CPP#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=25,inf=1e18;
struct Node{
string a,b;
bool operator <(const Node &u)const{
return b>u.b;
}
}s[N];
int n,maxn=-inf;
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n;
for (int i=1;i<=n;i++){
cin>>s[i].a;
s[i].b=s[i].a;
if (s[i].a.length()>maxn)maxn=s[i].a.length();
}
for (int i=1;i<=n;i++){
while(s[i].b.length()<maxn){
char c=s[i].b[s[i].b.length()-1];
s[i].b.push_back(c);
}
}
sort(s+1,s+n+1);
for (int i=1;i<=n;i++){
cout<<s[i].a;
}
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...