Permutation Game

시간 제한2초메모리 제한2048 MB

요약
연결 그래프와 순열이 주어질 때 두 사람이 최선을 다해 플레이한 결과값을 구하고, 시뮬레이션 상대를 이겨 그 값 이상을 달성한다.
난이도

어려움10점 중 9점

유형
게임 이론, 그래프, 이분 탐색, 구현
정답자
아직 제출이 없습니다

문제

Alice and Bob are childhood friends, and they love playing intellectual games. Today, they are playing a new game on graphs.

The game set contains a connected graph with mm vertices, numbered from 00 to m−1m − 1, and ee edges, numbered from 00 to e−1e − 1. The ii-th edge connects vertices u\[i]u\[i] and v\[i]v\[i].

The game set also contains a permutation p\[0],p\[1],…,p\[n−1]p\[0], p\[1], \dots , p\[n − 1] of length nn, where m≤nm ≤ n. Permutation is an array in which each number from 00 to n−1n − 1 appears exactly once, in some order. The score of permutation pp is the number of indices ii such that p\[i]=ip\[i] = i.

The game will last for at most 1010010^{100} turns. In each turn, the following happens:

  1. If Alice decides to end the game, the game stops.
  2. Otherwise, Alice chooses distinct indices t\[0],t\[1],…,t\[m−1]t\[0],t\[1], \dots ,t\[m − 1], where 0≤t\[i]<n0 ≤ t\[i] < n. Note that, the game does not require t\[0]<t\[1]<⋯<t\[m−1]t\[0] < t\[1] < \dots < t\[m − 1].
  3. Bob chooses an index 0≤j<e0 ≤ j < e of the edges of the graph and swaps p\[t\[u\[j]]]p\[t\[u\[j]]] and p\[t\[v\[j]]]p\[t\[v\[j]]].

Alice wishes to maximize the final score of the permutation while Bob wishes to minimize the final score of the permutation.

Your task is to help Alice and play against Bob, whose moves are simulated by grader.

Let's define optimal score as the final score of the permutation if both Alice and Bob play optimally.

You will need to determine the optimal score of the permutation and then play the game with Bob to achieve at least that optimal score after some turns.

Note that Alice's strategy should work no matter what moves Bob makes, including if Bob makes unoptimal moves.

제한

  • 2≤m≤4002 ≤ m ≤ 400
  • m−1≤e≤400m − 1 ≤ e ≤ 400
  • 0≤u\[i],v\[i]<m0 ≤ u\[i], v\[i] < m
  • m≤n≤400m ≤ n ≤ 400
  • 0≤p\[i]<n0 ≤ p\[i] < n
  • The graph is connected, contains no self-loops or multiple edges.
  • pp is a permutation, i.e. p\[i]≠p\[j]p\[i] \ne p\[j] for any i≠ji \ne j.

예제

이 문제는 공개된 예제가 없습니다.