프로그래밍 공부

BOJ/백준 10815 숫자 카드 본문

Problem Solving/Baekjoon Online Judge

BOJ/백준 10815 숫자 카드

khj1999 2024. 9. 17. 15:35

https://www.acmicpc.net/problem/10815

 

c++ map을 알거나 Python dictionary를 안다면 쉽게 해결 할 수 있는 문제이지만 모르면 고생을 할꺼 같다

 

#include <iostream>
#include <map>
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    map<int, bool> mp;
    int n, m;
    cin >> n;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        mp[tmp] = true;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        int tmp;
        cin >> tmp;
        if(mp.find(tmp) != mp.end()){
            cout << 1 << ' ';
        }
        else{
            cout << 0 << ' ';
        }
    }
    return 0;
}

 

'Problem Solving > Baekjoon Online Judge' 카테고리의 다른 글

BOJ/백준 2606 바이러스  (0) 2024.09.20
BOJ/백준 19591 독특한 계산기  (0) 2024.09.19
BOJ/백준 2589 보물섬  (0) 2024.09.13
BOJ/백준 6593 상범 빌딩  (0) 2024.09.13
BOJ/백준 14940 쉬운 최단거리  (0) 2024.09.12
Comments