-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1181.cpp
55 lines (43 loc) · 898 Bytes
/
1181.cpp
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
//
// Created by 융미 on 2019-05-28.
//*1181 단어 정렬
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int n;
//comparator 작성
bool com(string a, string b)
{
if(a.length() < b.length()) return true;
if(a.length() == b.length()){
if(a < b) return true;
else return false;
}
return false;
}
set<string> s; //set은 기본적으로 중복된 값 허용 안함
vector<string> v;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
string tmp;
for(int i = 0; i<n; i++)
{
cin >> tmp;
s.insert(tmp);
}
for(set<string>::iterator it = s.begin(); it != s.end(); it++)
{
v.push_back(*it);
}
sort(v.begin(), v.end(), com);
for(int i = 0; i<v.size(); i++)
{
cout << v[i] << '\n';
}
return 0;
}