Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- int main()
- {
- _test
- {
- int n;
- cin>>n;
- vector<ll int> a(n);
- for(auto &e: a) cin>>e;
- ll int ans = 0;
- map<int, int> mp;
- for(auto e: a)
- {
- ans += mp[e];
- mp[e]++;
- if(e == 1) ans += mp[2];
- if(e == 2) ans += mp[1];
- }
- cout<<ans<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment