반응형
#include <bits/stdc++.h>
using namespace std;
vector<string> v;
bool compare(string front , string back)
{
if(front.size() == back.size())
{
if( front.compare(back) ==-1) return front < back;
else if (front.compare(back)) return front < back;
else front > back;
}else{
return front.size() < back.size();
}
}
int main(void)
{
int N;
cin >> N;
for(int i = 0 ; i< N; i++)
{
string temp;
cin >> temp;
v.push_back(temp);
}
sort(v.begin(), v.end(), compare);
v.erase(unique(v.begin(), v.end()), v.end());
for(int i = 0 ; i< v.size(); i++)
{
cout << v[i] << endl;
}
}
v.erase 유용했다.
반응형
'Algorithm > Problem Solve' 카테고리의 다른 글
[백준 1920번] 수 찾기 (0) | 2020.12.11 |
---|---|
[백준1874번] 스택 수열 (0) | 2020.12.11 |
[백준1260번] BFS와 DFS (0) | 2020.12.09 |
[백준 1654번] 랜선자르기 (0) | 2020.12.08 |
[백준 1152번] 단어의 개수 (0) | 2020.12.07 |