CF Codeforces Round #258 (Div. 2) B (451B)
题意:找出一段逆序!
预存a[]数组到b[]数组。将b排序,然后前后找不同找到区间[l,r],然后推断[l,r]是否逆序就能够了!。当然还得特判本身就是顺序的!!
!
AC代码例如以下:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std; int a[100005],b[100005]; int main()
{
int n;
int i;
while(cin>>n)
{
memset(a,0,sizeof a);
memset(b,0,sizeof b);
for(i=0;i<n;i++)
{cin>>a[i];
b[i]=a[i];}
sort(b,b+n);
int flag1=1;
for(i=0;i<n;i++)
{
if(a[i]!=b[i])
{flag1=0;break;}
}
if(flag1)
{
cout<<"yes"<<endl<<"1"<<" "<<"1"<<endl;
continue;
}
int flag=0;
int l=0,r=n-1;
for(i=0;i<n;i++)
{
if(a[i]!=b[i])
{
l=i;
break;
}
}
for(i=n-1;i>=0;i--)
{
if(a[i]!=b[i])
{
r=i;
break;
}
}
for(i=l+1;i<=r;i++)
{
if(a[i]>a[i-1])
{flag=1;break;}
}
if(flag)
cout<<"no"<<endl;
else cout<<"yes"<<endl<<l+1<<" "<<r+1<<endl;
}
return 0;
}
CF Codeforces Round #258 (Div. 2) B (451B)的更多相关文章
- Codeforces Round #258 (Div. 2) 小结
A. Game With Sticks (451A) 水题一道,事实上无论你选取哪一个交叉点,结果都是行数列数都减一,那如今就是谁先减到行.列有一个为0,那么谁就赢了.因为Akshat先选,因此假设行 ...
- Codeforces Round #258 (Div. 2)[ABCD]
Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...
- CF Codeforces Round #231 (Div. 2)
http://codeforces.com/contest/394 话说这次CF做的超级不爽,A题一开始交过了,我就没再管,B题还没看完呢,就死困死困的,后来觉得B题枚举一下估计能行,当时是觉得可以从 ...
- [cf]Codeforces Round #784(Div 4)
由于一次比赛被虐得太惨,,生发开始写blog的想法,于是便有了这篇随笔(找了个近期的cf比赛练练手(bushi))第一次写blog,多多包涵. 第二场cf比赛,第一场打的Div2,被虐太惨,所以第二场 ...
- Codeforces Round #258 (Div. 2) B. Sort the Array
题目链接:http://codeforces.com/contest/451/problem/B 思路:首先找下降段的个数,假设下降段是大于等于2的,那么就直接输出no,假设下降段的个数为1,那么就把 ...
- Codeforces Round #258 (Div. 2) E. Devu and Flowers 容斥
E. Devu and Flowers 题目连接: http://codeforces.com/contest/451/problem/E Description Devu wants to deco ...
- Codeforces Round #258 (Div. 2) D. Count Good Substrings 水题
D. Count Good Substrings 题目连接: http://codeforces.com/contest/451/problem/D Description We call a str ...
- Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game 水题
C. Predict Outcome of the Game 题目连接: http://codeforces.com/contest/451/problem/C Description There a ...
- Codeforces Round #258 (Div. 2) . Sort the Array 贪心
B. Sort the Array 题目连接: http://codeforces.com/contest/451/problem/B Description Being a programmer, ...
随机推荐
- ASP.NET自定义控件加载资源WebResource问题
最近项目用日期控件,想把My97的资源文件跟TextBox封装成一个DatePicker控件,其实很简单的意见事情,但是还是用了一天多的时间,主要的问题就是解决资源文件加载的问题.通过一天多的努力,得 ...
- git创建与合并分支
创建与合并分支 在版本回退里,你已经知道,每次提交,Git都把它们串成一条时间线,这条时间线就是一个分支.截止到目前,只有一条时间线,在Git里,这个分支叫主分 支,即master分支.HEAD严格来 ...
- 50% 的财富 500 强企业使用 Windows Azure
在上周的北美TechEd大会上,我有幸见到了来自世界各地的客户.合作伙伴和分析师,其数量之多,让人震惊.没有什么比亲耳聆听使用 Windows Azure 来开创新天地的客户亲口讲述他们的故事更令人振 ...
- Codeforces 306B
#include <cstdio> #include <algorithm> #include <cstring> #include <cstdlib> ...
- Android GUI Building Blocks
说明:此笔记为“Android开发”学习视频的笔记,链接如下:http://open.163.com/movie/2010/1/8/D/M79HE97C3_M79HEQJ8D.html 一, Acti ...
- ByteBuffer用法总结
转自:http://blog.csdn.net/mars5337/article/details/6576417 在NIO中,数据的读写操作始终是与缓冲区相关联的.读取时信道(SocketChanne ...
- C#下使用GDAL
參考博客:http://blog.csdn.net/rrrrssss00/article/category/915498.以及viewmode=contents">李民录老师专栏.ht ...
- 折叠Collapse插件
实例 折叠(Collapse)插件可以很容易地让页面区域折叠起来.无论您用它来创建折叠导航还是内容面板,它都允许很多内容选项. .collapse 隐藏内容. .collapse.in 显示内容. . ...
- MOSS2010部署解决方案失败是可以尝试更新
update-spsolution -identity XXX.wsp -literalpath D:\SPS2010Setup\XXX.wsp -gacdeployment
- .net通用权限框架C/S概览
通用权限框架cs部分 先概述一下,cs使用vs2010+sql2008 和bs公用同一个数据库 为使界面好看使用了第三方控件 donetbar和devexpress,正版是要收费的,但是你们都明白的可 ...