最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題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關(guān)鍵字專題關(guān)鍵字專題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
當(dāng)前位置: 首頁 - 科技 - 知識百科 - 正文

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

來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間: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
推薦度:
導(dǎo)讀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].



醉了,寫了半天不對,原來又是把題目看錯(cuò)了。翻轉(zhuǎ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"<

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。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
推薦度:
標(biāo)簽: the bb codeforcesround#
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

專題
Top