https://www.acmicpc.net/problem/1620
1620번: 나는야 포켓몬 마스터 이다솜
첫째 줄에는 도감에 수록되어 있는 포켓몬의 개수 N이랑 내가 맞춰야 하는 문제의 개수 M이 주어져. N과 M은 1보다 크거나 같고, 100,000보다 작거나 같은 자연수인데, 자연수가 뭔지는 알지? 모르면
www.acmicpc.net
// 회사에 있는 사람
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
ios::sync_with_stdio(0),cin.tie(0);
unordered_map<string, int> map;
int size, n;
string input;
vector<string> dogam;
cin >> size >> n;
dogam.push_back("mutz"); // 0번 더미 추가
for (int i = 1; i <= size; i++)
{
cin >> input;
map[input] = i;
dogam.push_back(input);
}
while (n--)
{
cin >> input;
if (isdigit(input[0])) // 숫자면
cout << dogam[stoi(input)] << '\n';
else
cout << map[input] << '\n';
}
}
'<algorithm> > 백준' 카테고리의 다른 글
백준 1920 수 찾기 c++ (0) | 2023.09.11 |
---|---|
백준 10816 숫자 카드 2 c++ (0) | 2023.09.11 |
백준 7785 (c++) 회사에 있는 사람 (0) | 2023.04.06 |
백준 1744 (c++) 수 묶기 (0) | 2023.03.23 |
백준 1700 (c++) 멀티탭 스케줄링 (0) | 2023.03.22 |