讨论 / (518)求助第3个点····哪错了
coldffire 2013-08-08 02:27:00
点我顶贴 收藏 删除
Unaccepted

测评机: Xeost[5]

得分: 90分

提交日期: 2010-8-13 15:58:00

有效耗时: 437毫秒

测试结果1: 通过本测试点|有效耗时62ms

测试结果2: 通过本测试点|有效耗时47ms

测试结果3: 测试结果错误.错误结果为:HIJACK

正确结果应为:Failed

测试结果4: 通过本测试点|有效耗时47ms

测试结果5: 通过本测试点|有效耗时47ms

测试结果6: 通过本测试点|有效耗时47ms

测试结果7: 通过本测试点|有效耗时47ms

测试结果8: 通过本测试点|有效耗时47ms

测试结果9: 通过本测试点|有效耗时46ms

测试结果10: 通过本测试点|有效耗时47ms

提交代码:

#include <iostream>

using namespace std;

char a[101],b[101],c[101],d[27],c1[101];

int i=0; //int 'A'=65

int main()

{

memset(d,0,sizeof(d));

cin>>a>>b>>c;

while(a[i])

{

if(d[int(a[i]-64)]==0) d[int(a[i]-64)]=b[i];

else if(d[int(a[i]-64)]!=b[i]) {cout<<"Failed";return 0;}

i++;

}

i=0;

for(int j=1;j<=26;j++) if(d[j]==0){cout<<"Failed";return 0;}

while(c[i])

{

c1[i]=d[int(c[i]-64)];

i++;

}

i=0;

while(c1[i]) {cout<<c1[i];i++;}

}

#1 海蓝@2010-10-22 07:36:00
回复 删除
数据没错。。。只是你没有考虑 类似...aacc...不可对应...eeee...这种情况

01.

#include<iostream>

02.

#include<stdio.h>

03.

using namespace std;

04.

char str[4][101];

05.

char chart[27];

06.

int len,len1;

07.

void creatchart()

08.

{

09.

int i;

10.

for(i=0;i<len;i++)

11.

{

12.

chart[(int)(str[0][i])-65]=str[1][i];

13.

}

14.

}

15.

void check()

16.

{

17.

int i,j,n=0;

18.

for(i=0;i<len;i++)

19.

{

20.

for(j=i+1;j<len;j++)

21.

{

22.

if((str[0][i]==str[0][j]&&str[1][i]!=str[1][j])||(str[0][j]!=str[0][i]&&str[1][j]==str[1][i]))

23.

{

24.

cout<<"Failed";

25.

exit(0);

26.

}

27.

}

28.

}

29.

for(i=0;i<len;i++)

30.

{

31.

if(str[3][i]!=-1)for(j=i+1;j<len;j++)

32.

{

33.

if(str[0][i]==str[0][j])str[3][j]=-1;

34.

}

35.

}

36.

for(i=0;i<len;i++)if(str[3][i]!=-1)n++;

37.

if(n!=26){cout<<"Failed";exit(0);}

38.

}

39.

void proc()

40.

{

41.

int i;

42.

for(i=0;i<len1;i++)

43.

{

44.

str[2][i]=chart[(int)(str[2][i])-65];

45.

}

46.

}

47.

int main()

48.

{

49.

gets(str[0]);

50.

gets(str[1]);

51.

gets(str[2]);

52.

for(len=0;str[0][len]!='\0';len++);

53.

for(len1=0;str[2][len1]!='\0';len1++);

54.

check();

55.

creatchart();

56.

proc();

57.

for(len=0;len<len1;len++)

58.

cout<<str[2][len];

59.

return 0;

60.

}

这是我的AC~

#2 yanchen@2010-11-05 02:49:00
回复 删除
判断是否满足"一一对应"

AADFF

GGGNN

这里A->G,同时D->G,不满足"一一对应"的规则

//我的AC

#include<stdio.h>

#include<string.h>

int main()

{

int i,j,k,len,len2;

char ch,s[103],s2[103],s3[103],a[28];

memset(a,0,sizeof(a));

scanf("%s%s%s",s,s2,s3);

len=strlen(s);

len2=strlen(s3);

for(i=0;i<len;i++)

{

if(a[s[i]-'A']==0)

a[s[i]-'A']=s2[i];

else

if(a[s[i]-'A']!=s2[i])

{printf("Failed");return 0;}

}

for(i=0;i<26;i++)//判断是否缺少密字

if(a[i]==0)

{printf("Failed");return 0;}

for(i=0;i<25;i++)//判断是否满足"一一对应",如A->A,B->A,就不满足

for(j=i+1;j<26;j++)

if(a[i]==a[j])

{printf("Failed");return 0;}

for(i=0;i<len2;i++)

printf("%c",a[s3[i]-'A']);

return 0;

}

#3 Ko_Knight@2013-08-08 02:27:00
回复 删除
貌似我也被坑了……

Orz。。。。。。

查看更多回复
提交回复