Problem Link : Bob and Indices
Category : Adhoc
Contest : December Circuits'23
#include "bits/stdc++.h" using namespace std; #define int long long int #define endl '\n' void input(vector<int> &nums) { for (int &num : nums) { cin >> num; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.precision(12); bool FILEIO = 1; if (FILEIO and fopen("in.txt", "r")) { freopen("B3.txt", "r", stdin); } int tc; cin >> tc; for (int tcase = 1; tcase <= tc; tcase++) { int n; cin >> n; vector<int> A(n), B(n), C(n); input(A); input(B); input(C); map<int, int> cache; for (int i = 0; i < n; i++) { cache[ B[ C[i] ] ]++; } int ans = 0; for (int x : A) { ans += cache[x]; } cout << ans << endl; }
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.