Post

백준 17219번, 비밀번호 찾기

백준 17219번 c++ 문제풀이


문제:

백준 17219

풀이:

  1. 사이트 주소와 비밀번호를 map에다가 저장해준다.
  2. 찾고자하는 비밀 번호의 주소를 map에서 찾는다.
  3. 출력.

코드:

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
29
30
31
32
33
#include <iostream>
#include <algorithm>
#include <map>


using namespace std;

int main(void){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,m;
    map <string,string> mapset;

    cin >> n >> m;

    for(int i=0; i<n;i++){
        string email, pwd;
        cin >> email >> pwd;

        mapset.insert(pair<string, string>(email, pwd));
    }


    for(int i=0;i<m;i++){
        string email;
        cin >> email;

        cout << mapset[email] << "\n";
    }
    return 0;   
}   

감사합니다.

This post is licensed under CC BY 4.0 by the author.