#P5149. 会议座位
会议座位
Description
The principal posted a seating chart on the campus network: teachers are arranged in a single row from left to right. The teachers were satisfied with this seating.
However, when the meeting started, the principal accidentally shuffled the seating chart, and the teachers became unhappy. The teachers do not care how much their own positions changed, but if there is a pair of teachers and such that in the original seating was to the left of , and now is to the right of , then this pair contributes one unit of dissatisfaction.
The principal wants to know the total dissatisfaction value of these teachers.
Input Format
The first line contains a positive integer , the number of teachers.
The second line contains strings, each being a teacher’s name (case-sensitive). This line represents the original seating chart.
The third line contains strings, representing the shuffled seating chart.
Output Format
One line containing a non-negative integer, the total dissatisfaction value.
3
Stan Kyle Kenny
Kyle Stan Kenny
1
5
A B C D E
B A D E C
3
Hint
- For of the testdata, .
- For of the testdata, , each teacher’s name has length at most , consists only of uppercase and lowercase letters, and all names are distinct. Names are case-sensitive.
Translated by ChatGPT 5
京公网安备 11011102002149号