Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

帮看一下有什么不对的地方

Posted by kevinCoder at 2010-11-28 14:16:53 on Problem 1056
//============================================================================
// Name        : 1056IMME.cpp
// Author      : kevin
// Version     :
// Copyright   : copyright @ kevin
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	string tmp1,tmp2;
	int cases=0;
	int len;
	bool flag;
	string s[10000];
	int cnt=0;
	while(cin>>tmp1){
		flag=false;
		s[cnt++]=tmp1;
		while(cin>>tmp2){
			if(tmp2=="9"){
				cases++;
				break;
			}
			s[cnt++]=tmp2;
		}
		sort(s,s+cnt);
		for(int i=0;i<cnt;i++){
			len=s[i].length();
			for(int j=i+1;j<cnt;j++){
				string sub=s[j].substr(0,len);
				if(s[i]==sub){
					cout<<"Set "<<cases<<" is not immediately decodable"<<endl;
					flag=true;
					break;
				}
			}
			if(flag)
				break;
		}
		if(!flag)
			cout<<"Set "<<cases<<" is immediately decodable"<<endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator