Notice
Recent Posts
Recent Comments
Link
Programmer
1181번 단어 정렬 본문
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
vector<string> str;
string s;
int inputLength;
bool chk(string a, string b) {
if (a.length() == b.length())
return a < b;
return a.length() < b.length();
}
void solve() {
cin >> inputLength;
for (int i = 0; i < inputLength; i++) {
cin >> s;
if(find(str.begin(), str.end(), s) == str.end())
str.push_back(s);
}
sort(str.begin(), str.end(), chk);
for (auto i : str)
cout << i << '\n'; //endl을 쓸 경우 시간 초과
}
int main() {
solve();
return 0;
}
'백준' 카테고리의 다른 글
1158 요세푸스 문제 (0) | 2020.04.13 |
---|---|
3986번 좋은 단어 (0) | 2020.04.04 |
10828번 스택 (0) | 2020.04.03 |
10845번 큐 (0) | 2020.04.02 |
Comments