#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair <int, int>;
int main () {
ios::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif
int n; cin >> n;
vector <string> v;
for (int i = 0; i < n; ++i) {
string s; cin >> s;
v.emplace_back(s);
}
sort(v.begin(), v.end(), [](string a, string b){return a.size() < b.size();});
vector <char> ans;
n = (int) v.size();
for (int i = 0; i < n; ++i) {
string s = v[i];
int sz = (int) s.size();
for (char ch : s) ans.emplace_back(ch);
ans.emplace_back('P');
if (i != n - 1) {
while (sz--) ans.emplace_back('-');
}
}
cout << (int) ans.size() << "\n";
for (auto c : ans) cout << c << "\n";
return 0;
}
/*
array bound?
overflow?
print newline after every cases
idea correct?
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
1452 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
2912 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
2884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |