Official
B - cat Editorial
by
B - cat Editorial
by
cn449
文字列の列を文字の長さの昇順にソートできればよいです。
一例として、ソートの比較関数を文字列の長さの比較として定めるような方法があります。
実装例
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> s(n);
for (int i = 0; i < n; i++) cin >> s[i];
sort(s.begin(), s.end(), [](string x, string y) { return x.size() < y.size(); });
string ans = "";
for (int i = 0; i < n; i++) ans += s[i];
cout << ans << '\n';
}
posted:
last update: