Official
C - Route Map Editorial by en_translator
Let \(T\) be the set of strings consisting of \(T_i \, (1 \leq i \leq M)\). The \(i\)-th \((1 \leq i \leq N)\) answer is Yes if and only if \(S_i\) belongs to \(T\).
It can be implemented with set
in Python or std::set
in C++.
Sample code (C++):
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<string> s(n), t(m);
for (string& x : s) {
cin >> x;
}
for (string& x : t) {
cin >> x;
}
set<string> rapid(t.begin(), t.end());
for (const string& x : s) {
cout << (rapid.count(x) ? "Yes" : "No") << '\n';
}
}
Sample code (Python)
n, m = map(int, input().split())
s = input().split()
t = set(input().split())
for x in s:
print("Yes" if x in t else "No")
posted:
last update: