CF 454B(Little Pony and Sort by Shift-序列位移后单调性判断及最小位移[水])
来源:互联网 发布:excel 去掉空格数据 编辑:程序博客网 时间:2024/06/05 18:58
直接模拟,注意各种情况
#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<functional>#include<iostream>#include<cmath>#include<cctype>#include<ctime>using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n) for(int i=n;i;i--)#define RepD(i,n) for(int i=n;i>=0;i--)#define Forp(x) for(int p=pre[x];p;p=next[p])#define Lson (x<<1)#define Rson ((x<<1)+1)#define MEM(a) memset(a,0,sizeof(a));#define MEMI(a) memset(a,127,sizeof(a));#define MEMi(a) memset(a,128,sizeof(a));#define INF (2139062143)#define F (100000007)#define MAXN (100000+10)long long mul(long long a,long long b){return (a*b)%F;}long long add(long long a,long long b){return (a+b)%F;}long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;}typedef long long ll;int n,a[MAXN];int main(){//freopen("Sort by Shift.in","r",stdin);//freopen(".out","w",stdout);scanf("%d",&n);For(i,n) scanf("%d",&a[i]);Fork(i,2,n){if (a[i-1]>a[i]){Fork(j,i+1,n) {if (a[j-1]>a[j]) {printf("-1\n");return 0;}} if (a[n]>a[1]) {printf("-1\n");return 0;}printf("%d\n",n-i+1);return 0;}}printf("0\n");return 0;}
0 0
- CF 454B(Little Pony and Sort by Shift-序列位移后单调性判断及最小位移[水])
- CF 454 B. Little Pony and Sort by Shift
- CF 454B Little Pony and Sort by Shift
- B. Little Pony and Sort by Shift
- B - Little Pony and Sort by Shift
- CF 454B Little Pony and Sort by Shift KMP算法简单运用
- Codeforces 454B. Little Pony and Sort by Shift
- Codeforces 454B Little Pony and Sort by Shift(水题)
- CodeForces 454B Little Pony and Sort by Shift
- Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shift(序列)
- Little Pony and Sort by Shift
- Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shift
- Codeforces Round #259 (Div. 2)-B. Little Pony and Sort by Shift
- Codeforces #259 (Div. 2) B. Little Pony and Sort by Shift
- Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shift(模拟)
- Codeforces Div. 2 #259-B. Little Pony and Sort by Shift
- Codeforces Round #259 (Div. 2) B - Little Pony and Sort by Shift
- Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shift
- java中的接口
- MAC和PHY的区别
- Linux下ALSA声卡编程
- SQL注入原理讲解,很不错!
- android中handler详解
- CF 454B(Little Pony and Sort by Shift-序列位移后单调性判断及最小位移[水])
- 找工作笔试面试那些事儿(9)---数据库知识总结(1)
- 黑马程序员_java常用API之String
- 雾山的Java学习笔记---I/O(一)(字节流)
- 网站福音 多站点使用整改反馈功能免受罚
- Ubuntu 的libstdc++.so.5安装
- POJ 1128 Frame Stacking
- 委托和事件很好的说明
- uva 10375 唯一分解定理 筛法求素数【数论】