标签:技术 ber points statement lap alt pac 有一个 ble
Chef and Rainbow Array Problem Code: RAINBOWA
Chef likes all arrays equally. But he likes some arrays more equally than others. In particular, he loves Rainbow Arrays.
An array is Rainbow if it has the following structure:
Help Chef in finding out if the given array is a Rainbow Array or not.
Input 3 19 1 2 3 4 4 5 6 6 6 7 6 6 6 5 4 4 3 2 1 14 1 2 3 4 5 6 7 6 5 4 3 2 1 1 13 1 2 3 4 5 6 8 6 5 4 3 2 1 Output yes no no
The first example satisfies all the conditions.
The second example has 1 element of value 1 at the beginning and 2 elements of value 1 at the end.
The third one has no elements with value 7 after elements with value 6.
————————————————————————————————————————
cc暂时没给中文翻译 所以只好搬英文辣
不然我简述一下题意吧
就是要判断一个序列是否只出现并且都出现了1-7
还要求是个回文串并且只有一个峰(也就是单峰)
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int inf=0x3f3f3f3f; int read(){ int ans=0,f=1,c=getchar(); while(c<‘0‘||c>‘9‘){if(c==‘-‘) f=-1; c=getchar();} while(c>=‘0‘&&c<=‘9‘){ans=ans*10+(c-‘0‘); c=getchar();} return ans*f; } int T,n,s[257],c[257]; int main() { T=read(); while(T--){ bool f=false; memset(c,0,sizeof(c)); n=read(); for(int i=1;i<=n;i++){ s[i]=read(); if(s[i]>7||s[i]<1) f=1; else c[s[i]]=1; } for(int i=1;i<=7;i++) if(!c[i]) f=1; if(f){printf("no\n"); continue;} int cnt=(n+1)/2; s[0]=-inf; s[n+1]=-inf; for(int i=1,j=n;i<=cnt;i++,j--) if(s[i]!=s[j]||s[i]<s[i-1]||s[j]<s[j+1]){ printf("no\n"); f=1; break; } if(!f) printf("yes\n"); } return 0; }
codechef AUG17 T1 Chef and Rainbow Array
标签:技术 ber points statement lap alt pac 有一个 ble
原文地址:http://www.cnblogs.com/lyzuikeai/p/7287282.html