0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 22:08:47 +00:00

C - Neo-lexicographic Ordering

https://atcoder.jp/contests/abc219/submissions/25939143
This commit is contained in:
Baoshuo Ren 2021-09-18 22:38:51 +08:00 committed by Baoshuo Ren
parent 520a64a9ed
commit 4ebef12cae
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

33
AtCoder/ABC219/C/C.cpp Normal file
View File

@ -0,0 +1,33 @@
#include <bits/stdc++.h>
using namespace std;
int n;
map<char, int> m;
string a, s[50005];
int main() {
std::ios::sync_with_stdio(false);
cin >> a;
for (int i = 0; i < a.size(); i++) {
m[a[i]] = i;
}
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s[i];
}
sort(s, s + n, [](string a, string b) {
string aa, bb;
for (char c : a) {
aa.push_back(m[c] + 'a');
}
for (char c : b) {
bb.push_back(m[c] + 'a');
}
return aa < bb;
});
for (int i = 0; i < n; i++) {
cout << s[i] << endl;
}
return 0;
}