#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N, M;
cin >> N;
vector<int>v;
for (int i = 0; i < N; i++) {
int number; cin >> number;
v.push_back(number);
}
sort(v.begin(), v.end());
cin >> M;
for (int i = 0; i < M; i++) {
int start = 0;
int end = N - 1;
int check;
cin >> check;
while (start <= end) {
int mid = (start + end) / 2;
if (v[mid] == check) { //์ฐพ๋๊ฐ์ด ์์ผ๋ฉด ์ถ๋ ฅ
cout << 1 << " ";
break;
}
else if (v[mid] < check) { //์ฐพ๋๊ฐ์ด ๋ ํฌ๋ฉด ์ค๋ฅธ์ชฝํ์
start = mid + 1;
}
else { //์ฐพ๋ ๊ฐ์ด ์์ผ๋ฉด ์ผ์ชฝ ํ์
end = mid - 1;
}
if (start > end) cout << 0 << " ";
}
}
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 10818๋ฒ - ์ต์, ์ต๋ (0) | 2021.10.24 |
---|---|
[๋ฐฑ์ค,c++] 10817๋ฒ - ์ธ ์ (0) | 2021.10.24 |
[๋ฐฑ์ค,c++] 10816๋ฒ - ์ซ์์นด๋ 2 (0) | 2021.10.24 |
[๋ฐฑ์ค,c++] 10814๋ฒ - ๋์ด์ ์ ๋ ฌ (0) | 2021.10.24 |
[๋ฐฑ์ค,c++] 10811๋ฒ - ๋ฐ๊ตฌ๋ ๋ค์ง๊ธฐ (0) | 2021.10.24 |
[๋ฐฑ์ค,c++] 10809๋ฒ - ์ํ๋ฒณ ์ฐพ๊ธฐ (0) | 2021.10.23 |
๋๊ธ