This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |