아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Group tournament

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

요약
일부 결과가 정해진 리그전 표에서 남은 경기의 결과를 정해 각 팀의 최종 승점이 주어진 값과 정확히 일치하도록 채운다.
난이도

보통10점 중 7점

유형
그래프, 그리디, 구현, 수학
정답자
아직 제출이 없습니다

문제

In our capitalist-run, dog-eat-dog world money is everything, and big sports are no exception. All participating teams have already bought enough points for the next season, and all the local hockey federation has to do now is distribute the results of the upcoming games. However, some teams felt generous and apart from buying points also bought the results of some matches. Initially the federation officials thought it would only make their life easier: the more games are fixed, the less work. It was only later that they understood their wrong and asked us to be a part of their scheme and help them distribute the results of the games in the upcoming season.

The local hockey tournament follows a round scheme: NN teams participate, each team plays a game against each and every other team strictly once. Teams score points for games according to the following rules:

  • If the winning team is defined at the end of the regulation time of the match, it scores 3 points, and the other team gets none.
  • If a game is tied after regulation time, overtime ensues. In this case the winner gets 2 points and the loser gets 1. The overtime is unlimited and lasts until someone scores a goal.

Based on the tournament results, a team's score is calculated as the sum of its points earned in all games played.

입력

The first line of the input file contains an integer NN --- the number of tournament participants (2 ≤\leq NN ≤\leq 100). Teams are numbered from 1 to NN.

The following NN lines of the file each contain NN symbols and are in essence a tournament table for the given moment of time.

The symbol a_ija\_{ij} in the line ii and position jj denotes the result of a game scheduled to be played by team number ii against team number jj (1 ≤\leq ii, jj ≤\leq NN). It can be one of the following:

  • 'W' --- means that the team ii will win a match against jj in the regulation time
  • 'w' --- the team ii will win in a match against jj in the overtime
  • 'l' --- the team ii will lose to the team jj in the overtime
  • 'L' --- the team ii will lose to the team jj in the regulation time
  • '.' --- if the result of the game between ii and jj is not yet determined
  • '#' --- if ii equals jj, it means that there is no such game, i.e. a team cannot play against itself.

It is guaranteed that the table is correct. More formally:

  • a_ija\_{ij} = '#' for all ii = jj
  • if a_ija\_{ij} = '.', then a_jia\_{ji} = '.'
  • a_ija\_{ij} = 'W' when and only when a_jia\_{ji} = 'L'
  • a_ija\_{ij} = 'w' when and only when a_jia\_{ji} = 'l'

The last line of the input file contains NN integers p_ip\_i --- the number of points the ii-th team must score (1 ≤\leq ii ≤\leq NN).

출력

The output file must contain a completely filled tournament table in the same format as that in the input file.

It is guaranteed that a solution exists. If there are several solutions, print any of them.

예제1

  1. 예제 1

    입력
    4
    #..W
    .#w.
    .l#.
    L..#
    8 6 3 1
    
    예상 출력
    #wWW
    l#wW
    Ll#w
    LLl#