알고리즘

C++ 알고리즘 - 백준 10815 숫자 카드

마루설아 2025. 1. 11. 21:34

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

 

#include <bits/stdc++.h>
#include <unordered_map>
#define endl "\n"

using namespace std;

void CPP_INIT() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main(void) {
	CPP_INIT();

	int input1, input2;
	int num;
	vector<int> v;
	unordered_map<int, int> um;

	cin >> input1;

	for (int i = 0; i < input1; i++) {
		cin >> num;
		um.insert({ num, 1 });
	}

	cin >> input2;
	for (int i = 0; i < input2; i++) {
		cin >> num;
		v.push_back(num);
	}

	for (int i = 0; i < v.size(); i++) {
		if (um[v[i]]) cout << 1 << " ";
		else cout << 0 << " ";
	}
}