Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 누적 합
- 브루트포스
- ue5
- 유니티
- 백준
- 수학
- 트리
- BFS
- 우선순위 큐
- 정렬
- c++
- 백트래킹
- Unreal Engine 5
- 그리디 알고리즘
- 자료구조
- VR
- 재귀
- 다이나믹 프로그래밍
- 구현
- DFS
- 그래프
- 문자열
- XR Interaction Toolkit
- 다익스트라
- Team Fortress 2
- 스택
- 투 포인터
- 유니온 파인드
- 알고리즘
- 시뮬레이션
Archives
- Today
- Total
1일1알
백준 20291번 파일 정리 C++ 본문
map<string, int> 로 확장자의 개수를 저장하였다. map을 이용하면 자동으로 사전순으로 정렬된다.
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
#include <bitset>
using namespace std;
using int64 = long long;
int n;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
map<string, int> m;
for (int i = 0; i < n; i++) {
string str;
cin >> str;
string extension = "";
bool found = false;
for (int j = 0; j < str.length(); j++) {
if (found) extension += str[j];
if (str[j] == '.') found = true;
}
m[extension]++;
}
for (auto a : m) {
cout << a.first << " " << a.second << "\n";
}
}
'알고리즘' 카테고리의 다른 글
백준 24391번 귀찮은 해강이 C++ (0) | 2022.09.08 |
---|---|
백준 2607번 비슷한 단어 C++ (0) | 2022.09.07 |
백준 2146번 다리 만들기 C++ (0) | 2022.09.05 |
백준 1937번 욕심쟁이 판다 C++ (0) | 2022.09.04 |
백준 9466번 텀 프로젝트 C++ (0) | 2022.09.03 |