标签:style blog http color os 文件
http://acm.hnu.cn/online/?action=problem&type=show&id=12812
需要注意的细节很多 唉 看了modiz的代码 写出来的 自己代码能力太弱了 模拟题 atoi的头文件是stdio.h
1 #include<iostream> 2 #include<cstdlib> 3 #include<cstring> 4 #include<cstdio> 5 using namespace std; 6 #define ll __int64 7 char a[1100][1100]; 8 int b[1100]; 9 int n; 10 int main(){ 11 int i,j; 12 while(cin>>n &&n){ 13 int t=0; 14 int f=0,o=0; 15 for(i=1;i<=n;i++){ 16 cin>>a[i]; 17 if(o>=2) f=1; 18 if(strstr(a[i],"x")) o++; 19 else o=0; 20 if(strstr(a[i],"x")==NULL && i!=1 && strstr(a[i-1],"x")==NULL){ 21 int k1=atoi(a[i]); 22 int k2=atoi(a[i-1]); 23 if(i%2==0){ 24 if(k1<=k2) f=1; 25 } 26 else if(k1>=k2) f=1; 27 } 28 if(strstr(a[i],"x")) 29 b[t++]=i; 30 } 31 if(f==1 || t==n){ 32 cout<<"none"<<endl; 33 continue; 34 } 35 else if(t==0){ 36 cout<<"ambiguous"<<endl; 37 continue; 38 } 39 ll min=-1e9-100,max=1e9+100; 40 for(i=0;i<t;i++){ 41 if(b[i]%2==0){ 42 if(strstr(a[b[i]-1],"x")==NULL && b[i]-1!=0){ 43 int k=atoi(a[b[i]-1]); 44 if(min<k) min=k; 45 } 46 if(strstr(a[b[i]+1],"x")==NULL && b[i]+1<=n){ 47 int k=atoi(a[b[i]+1]); 48 if(min<k) min=k; 49 } 50 } 51 else { 52 if(strstr(a[b[i]-1],"x")==NULL && b[i]-1!=0){ 53 int k=atoi(a[b[i]-1]); 54 if(max>k) max=k; 55 } 56 if(strstr(a[b[i]+1],"x")==NULL && b[i]+1<=n){ 57 int k=atoi(a[b[i]+1]); 58 if(max>k) max=k; 59 } 60 } 61 } 62 //cout<<"max="<<max<<"min="<<min<<endl; 63 if(max-min==2) cout<<min+1<<endl; 64 else if(max-2>min) cout<<"ambiguous"<<endl; 65 else cout<<"none"<<endl; 66 } 67 return 0; 68 }
hnu 7/19 A Broken Audio Signal,布布扣,bubuko.com
hnu 7/19 A Broken Audio Signal
标签:style blog http color os 文件
原文地址:http://www.cnblogs.com/acplayfacm/p/3858836.html