提交时间:2024-01-23 15:04:13

运行 ID: 124577

#include <bits/stdc++.h> using namespace std; string p[10000]; int main() { int times=0,ans=0,len1,len2; while (cin>>p[times]) { times++; } sort(p,p+times); for (int i=0;i<=times;i++) { len1=p[i].length(); len2=p[i+1].length(); for (int j=0;j<=min(len1,len2);j++) { if (p[i][j]!=p[i+1][j]) ans++; } ans+=max(len1,len2)-min(len1,len2); } cout<<ans/2+1<<endl; return 0; }