#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
vector<string> v(n);
for(auto &x : v)cin >> x;
vector<vector<string>> out(21);
vector<int> used(n,0);
int ls = -1, lsn = 0;
for(int i = 0; i < n; ++i){
if((int)v[i].size() > lsn){
lsn = v[i].size();
ls = i;
}
}
cout << v[ls] << "\n";
for(int i = 0; i < lsn; ++i){
for(int j = 0; j < n; ++j){
if(used[j])continue;
if((int)v[j].size() < i){out[i].push_back(v[j]);used[j] = 1;}
if(v[ls][i] != v[j][i]){out[i].push_back(v[j]);used[j] = 1;}
}
}
for(int i = 0; i < n; ++i){
if(!used[i])out[20].push_back(v[i]);
}
for(int i = 0; i < 21; ++i){
sort(out[i].begin(),out[i].end());
}
string cur;
vector<char> oututo;
for(auto x : out){
for(auto y : x){
int go = min(cur.size(),y.size());
for(int i = 0; i < min((int)cur.size(),(int)y.size()); ++i){
if(cur[i] != y[i]){go = i; break;}
}
while(go < (int)cur.size()){
cur.pop_back();
oututo.push_back('-');
}
for(int i = go; i < (int)y.size(); ++i){
oututo.push_back(y[i]);
cur+=y[i];
}
oututo.push_back('P');
}
}
cout << oututo.size() << "\n";
for(auto x : oututo)cout << x << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Expected integer, but "tptttykduyvxjbzhqup" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Expected integer, but "labfaryosskugbkiuffd" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Expected integer, but "pwfxlmwfirlgbdevjd" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Expected integer, but "ixomsgennpdlurnmv" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Expected integer, but "heynorwrbizai" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
512 KB |
Expected integer, but "dncclviwgdudcybahuw" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
896 KB |
Expected integer, but "mzzuknicjtukmwmlddz" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
1780 KB |
Expected integer, but "ulgkwzakqubhstcdq" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
3788 KB |
Expected integer, but "lznhbvobjbxuwlhzwchf" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
53 ms |
3696 KB |
Expected integer, but "enjjtearnhdje" found |
2 |
Halted |
0 ms |
0 KB |
- |