티스토리 뷰

https://server-technology.tistory.com/269

 

[백준 C++] 1620번 나는야 포켓몬 마스터 이다솜

#include #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; (cin >> n >> m).ignore(); map m1; map m2; for (int i = 0; i < n; i++) { string str; getline(cin, str); m1[i + 1] = str;

server-technology.tistory.com


#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m;
    (cin >> n >> m).ignore();

    map<int, string> m1;
    map<string, int> m2;
    for (int i = 0; i < n; i++) {
        string str;
        getline(cin, str);
        m1[i + 1] = str;
        m2[str] = i + 1;
    }

    for (int i = 0; i < m; i++) {
        string str;
        getline(cin, str);
        if (atoi(str.c_str())) {
            cout << m1[stoi(str)] << '\n';
        } else {
            cout << m2[str] << '\n';
        }
    }
}
Total
Today
Yesterday
최근에 올라온 글
«   2024/11   »
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