-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
40 lines (39 loc) · 669 Bytes
/
B.cpp
File metadata and controls
40 lines (39 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<bits/stdc++.h>
using namespace std;
bool compare(string s1,string s2)
{
return s1.length()<s2.length();
}
int main()
{
int n;
string s1,s2;
cin>>n;
vector <string> v(n);
for(int i=0;i<n;i++)
{
cin>>v[i];
}
sort(v.begin(),v.end(),compare);
//
for(int i=0;i<n;i++)
{
if(i+1<n)
{
s1=v[i];
s2=v[i+1];
size_t f=s2.find(s1);
if(f==string::npos)
{
cout<<"NO";
return 0;
}
}
}
cout<<"YES"<<endl;
for(int i=0;i<n;i++)
{
cout<<v[i]<<endl;
}
return 0;
}