• <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
            數(shù)據(jù)加載中……

            SRM549 DIVⅡ 1000pt(AOV網(wǎng)拓?fù)渑判颍?/a>

            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>。求最小的轉(zhuǎn)換Y或者N,使該圖沒有環(huán)!

            思路:怎么做呢?thinking




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

            久久久久久久女国产乱让韩| 97久久超碰国产精品旧版| 潮喷大喷水系列无码久久精品| 男女久久久国产一区二区三区| 亚洲va久久久噜噜噜久久| 999久久久国产精品| 久久er国产精品免费观看8| 伊人久久大香线蕉精品不卡| 久久精品亚洲一区二区三区浴池 | 国产精品一区二区久久精品涩爱| 亚洲日韩中文无码久久| 精品999久久久久久中文字幕| 久久久久久综合网天天| 久久人妻少妇嫩草AV无码专区| 精品无码人妻久久久久久| 麻豆av久久av盛宴av| 国产—久久香蕉国产线看观看| 久久久无码精品亚洲日韩蜜臀浪潮| 日韩一区二区久久久久久| 中文字幕日本人妻久久久免费| 国产福利电影一区二区三区,免费久久久久久久精 | 国产亚洲成人久久| 日韩久久久久久中文人妻| 国产高潮久久免费观看| 国产精品久久久久久一区二区三区| 亚洲国产综合久久天堂 | 欧美精品一区二区久久| 久久无码高潮喷水| 亚洲国产成人久久综合一| 久久人人爽人人爽人人AV| 久久天天婷婷五月俺也去| 久久中文精品无码中文字幕| 久久大香香蕉国产| 亚洲成色WWW久久网站| 久久男人Av资源网站无码软件| 97精品伊人久久久大香线蕉| 国产国产成人精品久久| 久久99国产乱子伦精品免费| 亚洲AV无码久久精品成人 | 岛国搬运www久久| 91精品国产高清久久久久久国产嫩草|