abc188_b - Orthogonality
10 Jan 2021 — Tags: implementation,easy — URLStraightforward implementation of dot product.
Time complexity: $O(n)$
Memory complexity: $O(n)$
Click to show code.
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<ll>;
bool solve(vi a, vi b)
{
vi ans(a.size());
transform(begin(a), end(a), begin(b), begin(ans), multiplies<ll>());
return accumulate(begin(ans), end(ans), 0LL) == 0;
}
int main(void)
{
ios::sync_with_stdio(false), cin.tie(NULL);
int n;
cin >> n;
vi a(n), b(n);
for (auto &ai : a)
cin >> ai;
for (auto &bi : b)
cin >> bi;
cout << (solve(a, b) ? "Yes" : "No") << endl;
return 0;
}