728x90
반응형
https://www.acmicpc.net/problem/20291
20291번: 파일 정리
친구로부터 노트북을 중고로 산 스브러스는 노트북을 켜자마자 경악할 수밖에 없었다. 바탕화면에 온갖 파일들이 정리도 안 된 채 가득했기 때문이다. 그리고 화면의 구석에서 친구의 메시지를
www.acmicpc.net
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main() {
int n;
cin >> n;
string str;
map<string, int> m;
for(int i = 0; i < n; i++){
cin >> str;
int idx = str.find('.');
str = str.substr(idx + 1);
if(m.find(str) != m.end()){
m[str]++;
} else {
m[str] = 1;
}
}
for(auto iter = m.begin(); iter != m.end(); iter++){
cout << iter->first << " " << iter->second << endl;
}
return 0;
}
728x90
반응형
'Algorithm > BAEKJOON' 카테고리의 다른 글
[BOJ] 2941번 크로아티아 알파벳 (C++) (0) | 2022.02.03 |
---|---|
[BOJ] 23028번 5학년은 다니기 싫어요 (C++) (0) | 2022.02.02 |
[BOJ] 18870번 좌표 압축 (C++) (0) | 2022.01.30 |
[BOJ] 10988번 팰린드롬인지 확인하기 (C++) (0) | 2022.01.28 |
[BOJ] 7576번 토마토 (C++) (0) | 2022.01.28 |