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:
parent
520a64a9ed
commit
4ebef12cae
33
AtCoder/ABC219/C/C.cpp
Normal file
33
AtCoder/ABC219/C/C.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user