# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
237244 | wildturtle | Type Printer (IOI08_printer) | C++17 | 1098 ms | 40208 KiB |
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;
long long n,k,maxx,idx;
pair < long long, string > A[500005];
string s1,s[500005];
vector < char> v;
int main() {
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n;
for(long long i=1;i<=n;i++) {
cin>>s[i];
if(maxx<s[i].size()) { maxx=s[i].size(); s1=s[i]; }
}
for(long long i=1;i<=n;i++) {
A[i].second=s[i]; k=0;
for(long long j=0;j<s[i].size();j++)
if(s[i][j]!=s1[j]) break;
else k++;
A[i].first=k;
}
sort(A+1,A+1+n);
idx=0;
for(long long i=1;i<=n;i++) {
for(long long j=idx;j<A[i].second.size();j++)
v.push_back(A[i].second[j]);
v.push_back('P');
if(i==n) break;
idx=A[i].second.size();
for(long long j=0;j<A[i].second.size();j++) {
if(A[i].second[j]!=A[i+1].second[j]) { idx=j; break; }
}
for(long long j=idx;j<A[i].second.size();j++)
v.push_back('-');
}
cout<<v.size()<<endl;
for(long long i=0;i<v.size();i++)
cout<<v[i]<<endl;
}
Compilation message (stderr)
# | 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... |