-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1181.cpp
More file actions
71 lines (52 loc) · 1.07 KB
/
1181.cpp
File metadata and controls
71 lines (52 loc) · 1.07 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// 1181.cpp
// algo
//
// Created by 박효정 on 2021/05/21.
//
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//구초제
struct a{
string s;
a(string ss){
s=ss;
}
bool operator <(const a & b)const{
if(s.size()==b.s.size()){
return s<b.s;
}
else {
return s.size()<b.s.size();
}
}
};
int main(){
cin.tie(0);
cout.tie(0);
std::ios::sync_with_stdio(false);
//입력받을 단어의 수
int cnt;
cin>>cnt;
vector<a> v;
//입력받을 문자열
string sub;
for(int i=0;i<cnt;i++){
cin>>sub;
v.push_back(a(sub));
}
//구조체에서 정의한것을 기준으로 정렬
sort(v.begin(), v.end());
//같은 문자열 생략하기 위해
string tmp="";
//문자열 출력
for(int i=0;i<cnt;i++){
if(tmp==v[i].s)
continue;
cout<<v[i].s<<"\n";
tmp=v[i].s;
}
return 0;
}