<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        CodeforcesRound#258(Div.2)B.SorttheArray_html/css

        來源:懂視網 責編:小采 時間:2020-11-27 15:58:55
        文檔

        CodeforcesRound#258(Div.2)B.SorttheArray_html/css

        CodeforcesRound#258(Div.2)B.SorttheArray_html/css_WEB-ITnose:B. Sort the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Being a programmer, you like arrays a lot. For your birthday, your friends have given you an a
        推薦度:
        導讀CodeforcesRound#258(Div.2)B.SorttheArray_html/css_WEB-ITnose:B. Sort the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Being a programmer, you like arrays a lot. For your birthday, your friends have given you an a

        B. Sort the Array

        time limit per test

        1 second

        memory limit per test

        256 megabytes

        input

        standard input

        output

        standard output

        Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers.

        Unfortunately, the size of a is too small. You want a bigger array! Your friends agree to give you a bigger array, but only if you are able to answer the following question correctly: is it possible to sort the array a (in increasing order) by reversing exactly one segment of a? See definitions of segment and reversing in the notes.

        Input

        The first line of the input contains an integer n (1?≤?n?≤?105) ? the size of array a.

        The second line contains n distinct space-separated integers: a[1],?a[2],?...,?a[n] (1?≤?a[i]?≤?109).

        Output

        Print "yes" or "no" (without quotes), depending on the answer.

        If your answer is "yes", then also print two space-separated integers denoting start and end (start must not be greater than end) indices of the segment to be reversed. If there are multiple ways of selecting these indices, print any of them.

        Sample test(s)

        Input

        33 2 1

        Output

        yes1 3

        Input

        42 1 3 4

        Output

        yes1 2

        Input

        43 1 2 4

        Output

        no

        Input

        21 2

        Output

        yes1 1

        Note

        Sample 1. You can reverse the entire array to get [1,?2,?3], which is sorted.

        Sample 3. No segment can be reversed such that the array will be sorted.

        Definitions

        A segment [l,?r] of array a is the sequence a[l],?a[l?+?1],?...,?a[r].

        If you have an array a of size n and you reverse its segment [l,?r], the array will become:

        a[1],?a[2],?...,?a[l?-?2],?a[l?-?1],?a[r],?a[r?-?1],?...,?a[l?+?1],?a[l],?a[r?+?1],?a[r?+?2],?...,?a[n?-?1],?a[n].



        醉了,寫了半天不對,原來又是把題目看錯了。翻轉序列中某一段能否使得序列遞增

        #include #include #include #include #include #include #define ll __int64ll a[100009];ll b[100009];using namespace std;int main(){ int n; while(~scanf("%d",&n)) { memset(a,0,sizeof a); for(int i=1;i<=n;i++) { scanf("%I64d",&a[i]); b[i]=a[i]; } sort(b+1,b+1+n); int st=1,en=1; for(int i=1;i<=n;i++) { if(a[i]!=b[i]) { st=i; break; } } for(int i=n;i>=1;i--) { if(a[i]!=b[i]) { en=i; break; } } for(int i=0;i<(en-st+1)/2;i++) { swap(a[en-i],a[st+i]); } int f=0; for(int i=1;i<=en;i++) { if(a[i]!=b[i]) { f=1; break; } } if(f) cout<<"no"<

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        CodeforcesRound#258(Div.2)B.SorttheArray_html/css

        CodeforcesRound#258(Div.2)B.SorttheArray_html/css_WEB-ITnose:B. Sort the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Being a programmer, you like arrays a lot. For your birthday, your friends have given you an a
        推薦度:
        標簽: the bb codeforcesround#
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 相泽南亚洲一区二区在线播放| 久久久久亚洲AV成人无码网站| 亚洲国产精品免费观看| 一级毛片不卡片免费观看| 亚洲AV无码专区电影在线观看 | 国产精品高清视亚洲精品| 亚洲免费一级视频| 亚洲国产高清美女在线观看| 免费大片黄在线观看yw| 天堂亚洲国产中文在线| 好男人看视频免费2019中文| 亚洲精品无码专区久久| 成年男女免费视频网站| 久久精品国产亚洲AV久| 午夜一级免费视频| 免费看又黄又爽又猛的视频软件| 亚洲中文无韩国r级电影 | 亚洲精品福利网站| 久久久久久国产精品免费免费| 亚洲精品女同中文字幕| 全黄a免费一级毛片人人爱| 中文字幕乱码系列免费| 亚洲精品国产免费| 日本特黄特黄刺激大片免费| 一级特黄a免费大片| 久久精品国产亚洲av高清漫画 | 亚洲视频免费在线看| 毛片免费在线观看网站| 色爽黄1000部免费软件下载| 亚洲桃色AV无码| 真人做人试看60分钟免费视频 | 国产精品亚洲四区在线观看| 免费无码A片一区二三区| 国产成人亚洲精品91专区高清| 亚洲国产午夜中文字幕精品黄网站 | 一本久久综合亚洲鲁鲁五月天| 九九美女网站免费| 亚洲高清免费视频| 免费观看美女用震蛋喷水的视频| 国产精品亚洲片在线花蝴蝶| 亚洲人成网站在线播放影院在线|