hnu 7/19 A Broken Audio Signal

來源:互聯網
上載者:User

標籤: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 }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.