Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
果断暴力,不解释!(附暴力AC Code)#include<iostream> #include<string> #include<algorithm> #define MAX 10000 using namespace std; struct A { string str; int len; }a[MAX]; int cmp(const void *a,const void *b) { return ((struct A *)a)->len - ((struct A *)b)->len; } int main() { string str[MAX],s; int Case=1,i=0,j,n; bool flag; while(cin>>a[i].str) { if(a[i].str=="9") goto begin;//谁说不能goto? else { a[i].len=a[i].str.size(); i++; continue; } begin: n=i; flag=true; qsort(a,n,sizeof(a[0]),cmp); for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { string temp(a[j].str,0,a[i].len); if(a[i].str==temp) { flag=false; i=MAX+8; } } } if(flag) cout<<"Set "<<Case++<<" is immediately decodable\n"; else cout<<"Set "<<Case++<<" is not immediately decodable\n"; i=0; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator