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>
#define ll long long
using namespace std;
int main() {
ll n;
cin >> n;
vector<string> p(n);
for (int i=0;i<n;i++) {
cin >> p[i];
}
sort(p.begin(),p.end(),[](auto&x,auto&y) {
if (x.substr(0,abs((signed)(x.size()-y.size()))) == y.substr(0,abs((signed)(x.size()-y.size())))) {
return true;
}
return x.size() < y.size();
});
string curr="";
string ans="";
for (int i=0;i<n;i++) {
while (curr.size() != 0 && curr != p[i].substr(0,curr.size())) {
ans+="-";
curr.pop_back();
}
ans+=p[i].substr(curr.size(),p[i].size()-curr.size());
curr=p[i];
ans+="P";
}
n = ans.size();
for (int i=0;i<n;i++) {
cout << ans[i] <<'\n';
}
return 0;
}
# | 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... |