2021.11.09_7701-염라대왕의이름정렬
본문 바로가기
알고리즘 모음집/New 알고리즘

2021.11.09_7701-염라대왕의이름정렬

by KyeongMin 2021. 11. 9.
728x90
반응형

소스코드

#include<iostream> #include<algorithm> #include<vector> using namespace std; int N; bool cmp(string a, string b) { if (a.size() == b.size())return a < b; return a.size() < b.size(); } vector<string> name; void initData() { scanf("%d", &N); name.clear(); for (int n = 0; n < N; n++) { string lifeName; cin >> lifeName; name.push_back(lifeName); } sort(name.begin(), name.end(), cmp); } int main(int argc, char** argv) { int test_case; int T; cin >> T; for (test_case = 1; test_case <= T; ++test_case) { initData(); printf("#%d\n", test_case); for (int n = 0; n < N; n++) { if (name[n] == name[n + 1]) { continue; } cout << name[n] << '\n'; } } return 0;//정상종료시 반드시 0을 리턴해야합니다. }

설계

  • 사실 정렬 문제는 라이브러리가 잘되어 있어서 쓰면되는데
  • 여기서 포인트는 중복인 것 출력 안되게 해주면됨

실수

  • 사이즈가 작은것이라는 우선 순위 정렬이 있었음
    • 이것을 빼먹은 것 빼고는 사실 38.45%가 이해가 되지 않음

문제 링크

7701-염라대왕의이름정렬

원본

https://github.com/3DPIT/AlgorithmFinal/blob/main/02.algorithmStudy/004.SW_Expert%EB%AC%B8%EC%A0%9C%ED%92%80%EC%9D%B4/2021/11/1109/1.7701-%EC%97%BC%EB%9D%BC%EB%8C%80%EC%99%95%EC%9D%98%EC%9D%B4%EB%A6%84%EC%A0%95%EB%A0%AC/2021.11.09_7701-%EC%97%BC%EB%9D%BC%EB%8C%80%EC%99%95%EC%9D%98%EC%9D%B4%EB%A6%84%EC%A0%95%EB%A0%AC.md

 

GitHub - 3DPIT/AlgorithmFinal

Contribute to 3DPIT/AlgorithmFinal development by creating an account on GitHub.

github.com

 

728x90
반응형

댓글