Блог пользователя mac_n_cheese_pog

Автор mac_n_cheese_pog, история, 3 года назад, По-английски

after thinking for 2 hours i cant solve this problem https://codeforces.com/edu/course/2/lesson/9/1/practice/contest/307092/problem/C can someone help me?

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
3 года назад, # |
Rev. 5   Проголосовать: нравится +3 Проголосовать: не нравится

Create a count map for array $$$b$$$, say $$$cnt$$$. Then iterate over $$$a$$$ and for each $$$a_i$$$, $$$ans$$$ is increased by $$$cnt[a_i]$$$. cmiiw!

for(int i = 1; i <= b.size(); i++){
cnt[b[i]]++;
}

for(int i = 1; i <= a.size(); i++){
ans += cnt[a[i]];
}