Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

aditya_patil71's blog

By aditya_patil71, history, 5 weeks ago, In English
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by aditya_patil71 (previous revision, new revision, compare).

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

You can refer to my solution https://mirror.codeforces.com/contest/1980/submission/265876558

the idea is simple we iterate through the indexes and for every index where a[i]!=b[i] we just check if there exists b[i] in the replacement queries if found we simply decrease the count of b[i] in the replacement queries, else we output NO. In the end we also have to check that the last query actually exists in the array "b" or not as we have to execute that too and if we execute a query on array "a" which is not present in "b" then the arrays would differ that's why we check that and print YES or NO accordingly.