Short Cake
8PM - Animal Crossing Wild World

사생활 보호 설정

https://gamjia.tistory.com

Mini Rooms

  • 내 미니룸
  • 미니미설정
  • 미니룸설정
  • 답글수 [0]

What Friends Say

한마디로 표현해봐~

1촌평 관리

1181번 단어 정렬

GamJia 2023. 4. 3. 09:12

단계별로 풀어보기 - 정렬 - 8단계

https://www.acmicpc.net/problem/1181

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

bool compare(string a, string b)
{
    if(a.size()==b.size())
    {
        return a<b;
    }
    
    else
    {
        return a.size()<b.size();
    }
}

int main()
{
    int N;
    vector <string>a;    
    cin>>N;
    
    for(int i=0;i<N;i++)
    {
        string word;
        cin>>word;
        a.push_back(word);
    }
    
    sort(a.begin(),a.end(),compare);
    a.erase(unique(a.begin(),a.end()),a.end());
    
    for(int i=0;i<a.size();i++)
    {
        cout<<a[i]<<"\n";
    }
    
    return 0;
}

'BaekJoon' 카테고리의 다른 글

11870번 좌표 압축  (0) 2023.04.03
10814번 나이순 정렬  (0) 2023.04.03
11651번 좌표 정렬하기 2  (0) 2023.04.03
11650번 좌표 정렬하기  (0) 2023.04.03
1427번 소트인사이드  (0) 2023.04.03