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

Re:大家小心密码串和明码串不等长的情况啊 也要输出NO的!!!!

Posted by quuni at 2012-03-13 13:53:51 on Problem 2159
In Reply To:大家小心密码串和明码串不等长的情况啊 也要输出NO的!!!! Posted by:3902100816 at 2011-07-19 19:21:07
> /*我submit了N次 就是不AC 上网问了大牛 才知道两个串是否等长需要判断……*/
> 
> #include<iostream>
> using namespace std;
> void QuickSort(char *p,int headmark,int tailmark)
> {
> 	if(headmark>=tailmark)//排序区域长度不大于1,不需再排
> 	{return;}
> 
> 	int temp,emp,big,small;
> 	temp=p[headmark];
> 	small=headmark;
> 	big=tailmark;
> 
> 	while(small<big)
> 	{
> 		while(small<big && p[big]>=temp)
> 			--big;
> 		p[small]=p[big];
> 
> 		while(small<big && p[small]<=temp)
> 			++small;
> 		p[big]=p[small];
> 	}
> 	emp=big;
> 	p[emp]=temp;//定位枢轴值
> 	QuickSort(p,headmark,emp-1);
> 	QuickSort(p,emp+1,tailmark);
> }
> 
> int main()
> {
> 	char code[100],mes[100];
> 	int i;
> 	while(cin>>code>>mes)
> 	//cin>>code>>mes;
> 	{
> 		int td;
> 		bool p=0,ga=0;
> 		for(td=0;td<=26;td++)
> 		{
> 			if(strlen(mes)!=strlen(code))//加了这句,果断AC- -!
> 				break;//容错考虑
> 			char temp[100];
> 			for(i=0;i<strlen(code);i++)
> 			{
> 				temp[i]=code[i];
> 			}
> 			p=1;
> 			for(i=0;i<strlen(code);i++)//先解开替代方式 
> 			{
> 				temp[i]=temp[i]-td;
> 				if(temp[i]<'A')
> 				{temp[i]='Z'-('A'-temp[i])+1;}
> 			}
> 			QuickSort(temp,0,strlen(code)-1);
> 			QuickSort(mes,0,strlen(code)-1);//快排替代的结果 
> 			for(i=0;i<strlen(code);i++)
> 			{
> 				if(mes[i]!=temp[i])
> 				{p=0;break;}
> 			}
> 			if(p)
> 			{ga=1;break;}
> 		}
> 		if(ga)
> 		cout<<"YES"<<endl;
> 		else
> 		cout<<"NO"<<endl;
> 	}
> 	return 0;
> }
>
》The lengths of both lines of the input are equal and do not exceed 100.
可测试数据又搞不相等的 这个有点忽悠人啊

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