포럼
문제 ICPC00176

G. Guessing Camels

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
설명

Jaap, Jan, and Thijs are on a trip to the desert after having attended the ACM ICPC World Finals 2015 in Morocco. The trip included a camel ride, and after returning from the ride, their guide invited them to a big camel race in the evening. The camels they rode will also participate and it is customary to bet on the results of the race.

One of the most interesting bets involves guessing the complete order in which the camels will finish the race. This bet offers the biggest return on your money, since it is also the one that is the hardest to get right.

Jaap, Jan, and Thijs have already placed their bets, but the race will not start until an hour from now, so they are getting bored. They started wondering how many pairs of camels they have put in the same order. If camel \(c\) is before camel \(d\) on Jaap's, Jan's and Thijs' bet, it means that all three of them put \(c\) and \(d\) in the same order. Can you help them to calculate the number of pairs of camels for which this happened?

제약
입력 형식

The input consists of:
- one line with an integer \(n\) (\(2\leq n \leq 200\,000\)), the number of camels;
- one line with \(n\) integers \(a_1, \ldots, a_n\) (\(1 \le a_i \le n\) for all \(i\)), Jaap's bet. Here \(a_1\) is the camel in the first position of Jaap's bet, \(a_2\) is the camel in the second position, and so on;
- one line with Jan's bet, in the same format as Jaap's bet;
- one line with Thijs' bet, in the same format as Jaap's bet.

The camels are numbered \(1, \dots, n\). Each camel appears exactly once in each bet.

출력 형식

Output the number of pairs of camels that appear in the same order in all \(3\) bets.

예제 1
입력
3
3 2 1
1 2 3
1 2 3
출력
0
예제 2
입력
4
2 3 1 4
2 1 4 3
2 4 3 1
출력
3
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NWERC 2015

평가 및 의견

G. Guessing Camels

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

G. Guessing Camels

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8