Submission #992075

#TimeUsernameProblemLanguageResultExecution timeMemory
992075oscar1fType Printer (IOI08_printer)C++17
100 / 100
87 ms4336 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int nbMots,rep,plusLong; string maxiMot; vector<string> motTri; int commun(string a,string b) { int ans=0; while (ans<(int)a.size() and ans<(int)b.size() and a[ans]==b[ans]) { ans++; } return ans; } void afficher(string a,int deb) { for (int i=deb;i<(int)a.size();i++) { cout<<a[i]<<"\n"; } cout<<"P"<<"\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>nbMots; string nouvMot; for (int i=0;i<nbMots;i++) { cin>>nouvMot; motTri.push_back(nouvMot); } sort(motTri.begin(),motTri.end()); for (int i=0;i<nbMots;i++) { rep+=2*motTri[i].size(); if ((int)motTri[i].size()>=plusLong) { plusLong=motTri[i].size(); maxiMot=motTri[i]; } } for (int i=0;i<nbMots-1;i++) { rep-=2*commun(motTri[i],motTri[i+1]); } rep-=plusLong; rep+=nbMots; cout<<rep<<"\n"; sort(motTri.begin(),motTri.end(),[&] (string a,string b) { if (commun(a,maxiMot)!=commun(b,maxiMot)) { return commun(a,maxiMot)<commun(b,maxiMot); } return a<b; }); afficher(motTri[0],0); int deb; for (int i=1;i<nbMots;i++) { deb=commun(motTri[i-1],motTri[i]); for (int j=(int)motTri[i-1].size()-1;j>=deb;j--) { cout<<"-"<<"\n"; } afficher(motTri[i],deb); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...