• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            ArcTan

            dfs
            隨筆 - 16, 文章 - 117, 評論 - 6, 引用 - 0
            數據加載中……

            SRM549 DIVⅡ 1000pt(AOV網拓撲排序)

            Problem Statement

                 The Order of the Hats is a magical organization. One of their duties is to teach students how to cast spells. There are N spells numbered from 0 to N-1. As an aid for the students, the teachers have prepared a spell chart. The chart lists suggestions on the order in which to study the spells. (This is explained in more detail below.)

            Recently, some changelings broke into the Order's spell archive and messed up the spell chart. You are given a String[] spellChart containing the new, messed-up state of the spell chart. Each character of each element of spellChart is either 'Y' or 'N'. The students will come to study soon. They will interpret the chart in the following way: If spellChart[i][j] is 'Y' then spell i must be learned before spell j.

            As the chart is now messed up, it may be impossible to learn all the spells in the chart because of cycles in the requirements. Your task is to repair the given chart. Determine the minimum number of changes needed to remove all the cycles in the requirements. In a single change, you may either change some character spellChart[i][j] from 'Y' to 'N', or change some character from 'N' to 'Y'.

            Definition

                
            Class: OrderOfTheHats
            Method: minChanged
            Parameters: String[]
            Returns: int
            Method signature: int minChanged(String[] spellChart)
            (be sure your method is public)
                

            Constraints

            - spellChart will contain between 1 and 20 elements, inclusive.
            - Each element of spellChart will contain N characters, where N is the number of elements in spellChart.
            - Each character in each element of spellChart will be either 'Y' or 'N'.

            Examples

            0)
                
            {"Y"}
            Returns: 1
            This spell chart contains a spell that should be learned before itself. The students would never be able to learn such a spell. We can remove this cyclic dependency by changing the 'Y' to 'N'.
            1)
                
            {"NYN",  "NNY",  "NNN"}
            Returns: 0
            This spell chart is already OK.
            2)
                
            {"NYN",  "NNY",  "YNN"}
            Returns: 1
            Changing any single 'Y' to a 'N' will fix this spell chart.
            3)
                
            {"NYYYYYY",  "YNYYYYY",  "YYNYYYY",  "YYYNYYY",  "YYYYNYY",  "YYYYYNY",  "YYYYYYN"}
            Returns: 21

            4)
                
            {"NNNY",  "YNYN",  "YNNN",  "YYYN"}
            Returns: 1

            5)
                
            {"YYYYYNNYYYNYNNNNYNNY",  "NYNNNYYNNYNYYYNYYYYY",  "NNYNNNYYNNNNNNYYYYNY",  "YYNYNYYNNYYYNYNNNYYY",  "NYYNNYNYNYNNNNYYYNYN",  "NNNNNYYNYNNYYYYNYYYN",  "YNYNYYNNNYNNNNNYNNYY",  "NYYYYNYNYNNYNNYNNNNY",  "YYYYNYYNNYYYNNYNNYNY",  "YYYYYYNYNYNYNNNNNNYN",  "NNYYYYYNNNYNNNYNNNNY",  "YYNNNYNYYNYYNYYNYNYN",  "NNYNYYNYYNYYNYNYNYYN",  "YNYNYYNYNNNYNYNYYNYY",  "NNYNNNYYYYYYYYYYYNYY",  "YYYYYNYYNYYYYYNNYNNN",  "NYYYYYYYYNNNNNYYNNYN",  "YNNYNNNYYNYYYNYNYYYY",  "YYNNYNYYYNYYNNNYYNNY",  "NNYNYNYYYNYYNYNNYNNN"}
            Returns: 79

            6)
                
            {"YYNYNN",  "YNYNNY",  "YYYYNN",  "NNNYNN",  "NNNYNN",  "YNYNYN"}
            Returns: 5

            7)
                
            {"NNNNNNNNNN",  "NNNNNNNNNN",  "NNNYNNYNNN",  "NNNYNNYNNN",  "NNNYNNYNNN",  "NNNNNNNNNN",  "NNYYYYYYNN",  "NNYNNNNYNN",  "NNNYYYYNNN",  "NNNNNNNNNN"}
            Returns: 6

            This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.




            題意:給定一張N*N的map,N個頂點的圖,map[i][j]=='Y',<i,j>,否則<j,i>。求最小的轉換Y或者N,使該圖沒有環!

            思路:怎么做呢?thinking




            posted on 2012-07-10 09:59 wangs 閱讀(252) 評論(0)  編輯 收藏 引用 所屬分類: Topcoder

            亚洲欧洲日产国码无码久久99| 久久婷婷是五月综合色狠狠| 久久精品夜夜夜夜夜久久| 99国产欧美久久久精品蜜芽| 亚洲国产成人久久综合野外| 久久亚洲精品视频| 久久精品无码专区免费青青| 久久99国产精品99久久| 色综合久久中文字幕无码| 久久精品国产亚洲AV无码娇色| 久久精品成人欧美大片| 久久99久久无码毛片一区二区| 精品国产一区二区三区久久| 久久久久久亚洲精品不卡| 少妇精品久久久一区二区三区| 国产成人精品久久一区二区三区av | 亚洲а∨天堂久久精品| 97久久国产露脸精品国产| 久久久久人妻精品一区三寸蜜桃| 国产AV影片久久久久久| 97久久国产综合精品女不卡| 国产精品狼人久久久久影院| 久久综合给合久久狠狠狠97色| 久久婷婷国产综合精品| 久久久久这里只有精品| 久久性生大片免费观看性| 国产精品欧美久久久天天影视| 国色天香久久久久久久小说| 四虎国产精品成人免费久久| 久久九九亚洲精品| 精品国产一区二区三区久久久狼| 久久国产色AV免费观看| 99精品国产综合久久久久五月天| 久久伊人色| 亚洲伊人久久成综合人影院| 久久www免费人成看国产片| 精品久久久久久久久久久久久久久| 97久久精品国产精品青草| 久久ZYZ资源站无码中文动漫| 久久青青草原精品国产| 亚洲精品乱码久久久久久蜜桃不卡|