반응형
https://www.acmicpc.net/problem/1620
// 회사에 있는 사람
#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 |