[요약] 미르코는 역사 시험에서 각 전쟁이 일어난 순서를 올바르게 써야 합니다. 그런데 제대로 정답을 쓰지 못하고 순서가 약간 뒤죽박죽이 되버렸는데 우리는 미르코의 점수를 계산해야합니다.
만점은 N*(N-1)/2 점입니다. 두 전쟁을 골랐을 때 앞에 있는 전쟁이 뒤에 있는 전쟁보다 먼저 일어난 전쟁이라면 1점, 아니면 0점입니다.
모든 전쟁을 비교했을 때 미르코가 몇 점 만점의 몇 점을 받았는지 출력 형식대로 출력하세요.
(전쟁의 이름은 3자 이상, 15자 이하입니다)
1. Blockade of Naboo 2. Battle of Geonosis 3. Battle of Yavin 4. Battle of Hoth 5. Battle of Endor
Mirko-wan has studied (relatively) hard for the exam, so he remembered the exact years of all battles, except for the Blockade of Naboo. He couldn't remember anything about it, so he randomly placed it last instead of first, obtaining the order:
1. Battle of Geonosis 2. Battle of Yavin 3. Battle of Hoth 4. Battle of Endor 5. Blockade of Naboo
Since Mirko-wan's order doesn't match the correct solution at any index, Mirko-wan's score on that problem was - to his disappointment - 0 out of 5 points, even though he knew the correct order of four out of five battles!
This opens the question of fair scoring of an ordering problem. The example given above suggests that scoring by counting the number of items in the correct absolute position isn't fair. Is there a better way? One possibility is finding the longest subsequence (not necessarily contiguous) of correctly ordered items. This isn't the best solution either: if an item is displaced by just one position from the correct order, the score that it awards drops to zero, even though it was almost correctly ordered.
Mirko-wan has thus suggested (using the MAWT - Might As Well Try a Mind Trick approach) the following scoring method to his history teacher. For every two items, the student will receive 1 point if the two items are in mutually correct order. In other words, the number of points is the number of item pairs that the student has correctly ordered. The maximum number of points is then, of course, the total number of pairs, which equals N * (N - 1) / 2, where N is the total number of entries.
input 3 alpha beta gamma alpha gamma beta output 2/3 input 5 naboo geonosis yavin hoth endor geonosis yavin hoth endor naboo output 6/10
출처:coci/2012-2013/contest3/2 번 요약:ladown21