题解

39 条题解

  • 0
    @ 2015-03-21 20:08:40

    仔细读题,想清楚题意再做。

    Pascal Code

    var
    a,b,c:string;
    p:array['A'..'Z'] of char; //下标为密文,值为原文
    hash:array['A'..'Z'] of boolean; //下标为原文,值表示这一原文有没有使用过
    i:longint;
    j:char;
    procedure fail;
    begin
    writeln('Failed');
    halt;
    end;
    begin
    readln(a);
    readln(b);
    readln(c);
    fillchar(p,sizeof(p),' ');
    fillchar(hash,sizeof(hash),0);
    if length(a)<>length(b) then fail;
    for i:=1 to length(a) do
    begin
    if (p[a[i]]<>b[i]) and (p[a[i]]<>' ') then fail;
    p[a[i]]:=b[i];
    end;
    for j:='A' to 'Z' do
    begin
    if (p[j]=' ') or hash[p[j]] then fail;
    hash[p[j]]:=true;
    end;
    for i:=1 to length(c) do
    write(p[c[i]]);
    end.

  • 0
    @ 2015-01-18 17:06:06

    #include<iostream>
    #include<string.h>
    using namespace std;
    int main()
    {
    string code, text, ncode, ntext;
    bool check = true, chr[26];
    char match[26];

    cin >> code >> text >> ncode;
    memset(chr,false,sizeof(chr));

    int len = code.length();
    int nlen = ncode.length();

    int i, j;
    //情况2

    if(check)
    {
    for(i = 0; i < len-1; i++)
    for(j = i+1; j < len; j++)
    {
    if((text[i] != text[j]) && (code[i] == code[j]))
    check = false;
    }

    }

    //情况3

    if(check)
    {
    for(i = 0; i < len; i++)
    chr[(int)text[i]-65] = true;
    for(i = 0; i < 26; i++)
    if(chr[i] == false) check = false;
    }

    if(check == false)
    {
    cout << "Failed" << endl;
    }
    else
    {
    for(i = 0; i < len; i++) //建立已知 密文 与 明文对应关系
    match[(int)code[i]-65] = text[i];
    for(i = 0; i < nlen; i++)
    cout << match[(int)ncode[i]-65];
    cout << endl;
    }

    return 0;
    }

  • 0
    @ 2014-11-06 19:28:10

    测试数据 #0: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 512 KiB, score = 10
    测试数据 #4: Accepted, time = 15 ms, mem = 504 KiB, score = 10
    测试数据 #5: Accepted, time = 15 ms, mem = 508 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #7: Accepted, time = 15 ms, mem = 508 KiB, score = 10
    测试数据 #8: Accepted, time = 15 ms, mem = 508 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    Accepted, time = 60 ms, mem = 512 KiB, score = 100
    代码
    #include <cstdio>
    #include <map>
    #include <string>
    #include <iostream>
    using namespace std;
    #define M 10000

    int ssize;
    string origin,sec,trans;
    map<char,char> dict;

    int main() {
    cin>>sec>>origin>>trans;
    ssize = sec.size();
    if(sec.size()<26) {
    printf("Failed\n");
    return 0;
    }
    if(sec.size()==26) {
    for(int i = 0; i < ssize; i++) {
    for(int j = 0; j < ssize&&i!=j; j++) {
    if(sec[i]==sec[j]||origin[i]==origin[j]) {
    printf("Failed\n");
    return 0;
    }
    }
    }
    }
    dict[sec[0]] = origin[0];
    for(int i = 1; i < ssize; i++) {
    if(dict[sec[i]]!=NULL && dict[sec[i]]!=origin[i]) {
    printf("Failed\n");
    return 0;
    }
    dict[sec[i]] = origin[i];
    }
    for(int i = 0; i < trans.size(); i++) {
    cout<<dict[trans[i]];
    }
    cout<<endl;
    return 0;
    }

  • 0
    @ 2014-11-05 22:56:47

    评测结果
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 848 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 848 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 852 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 848 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 848 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 848 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 848 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 856 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 852 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 848 KiB, score = 10
    Accepted, time = 0 ms, mem = 856 KiB, score = 100
    代码
    var s1,s2,s3:ansistring;
    s:array[1..26] of char;
    f:array[1..26] of boolean;
    i,len,j:longint;
    begin
    fillchar(s,sizeof(s),'0'); fillchar(f,sizeof(f),false);
    readln(s1);
    readln(s2);
    readln(s3);
    len:=length(s1);
    for i:=1 to len do begin
    f[ord(s1[i])-ord('A')+1]:=true;
    if s[ord(s1[i])-ord('A')+1]<>'0' then begin
    if s2[i]<>s[ord(s1[i])-ord('A')+1] then begin
    writeln('Failed');
    halt;
    end;
    end else s[ord(s1[i])-ord('A')+1]:=s2[i];
    end;
    for i:=1 to 26 do
    if not f[i] then begin
    writeln('Failed');
    halt;
    end;
    for i:=1 to 26 do
    for j:=i+1 to 26 do
    if s[i]=s[j] then begin
    writeln('Failed');
    halt;
    end;
    for i:=1 to length(s3) do
    write(s[ord(s3[i])-ord('A')+1]);
    end.

  • 0
    @ 2014-11-05 18:01:18

    测试数据 #0: Accepted, time = 0 ms, mem = 532 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 536 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 532 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 532 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 540 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 536 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 532 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 532 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 536 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 532 KiB, score = 10
    Accepted, time = 0 ms, mem = 540 KiB, score = 100
    ###_**C语言精简代码**_
    ****#include <stdio.h>****
    ****#include <string.h>****

    int main(){
    int i,s=0,pan=1;
    char s1[101],s2[101],s3[101],a[26]={0},b[26]={0};
    scanf("%s %s %s",s1,s2,s3);
    for (i=0;i<strlen(s1);i++) {
    if (a[s1[i]-'A']==0&&!b[s2[i]-'A'])
    {a[s1[i]-'A']=s2[i];s++;b[s2[i]-'A']=1;}
    if (a[s1[i]-'A']!=0&&a[s1[i]-'A']!=s2[i]||a[s1[i]-'A']==0&&b[s2[i]-'A'])
    pan=0; }
    for (i=0;i<strlen(s3);i++)
    if (s<26) pan=0;
    if (pan==1) {
    for (i=0;i<strlen(s3);i++)
    printf("%c",a[s3[i]-'A']); }
    else printf("Failed");
    return 0;
    }

  • 0
    @ 2014-11-04 08:08:04

    #include<iostream>
    #include<cstring>
    #include<cstdio>
    using namespace std;
    bool pan=true;
    char s1[102],s2[102],key[27],s3[102];
    int book[27]={0};
    int main()
    {
    scanf("%s%s",s1,s2);
    for(int i=0;i<(int)strlen(s1);i++){key[s1[i]-'A']=s2[i];}
    for(int i=0;i<(int)strlen(s2);i++){book[s2[i]-'A']=1;}
    for(int i=0;i<26;i++){if(book[i]==0){pan=false;break;}}
    scanf("%s",s3);
    for(int i=0;i<(int)strlen(s1);i++)
    for(int j=0;j<(int)strlen(s1);j++)
    if(s1[i]==s1[j]&&s2[i]!=s2[j]){pan=false;break;}
    if(!pan)cout<<"Failed"<<endl;

    if(pan==true)
    {
    for(int i=0;i<(int)strlen(s3);i++)
    {
    cout<<key[s3[i]-'A'];
    }
    }
    //while(1);
    return 0;
    }

  • 0
    @ 2014-11-03 23:35:40

    #include<iostream>
    #include<cstring>
    #include<cstdio>
    using namespace std;
    bool pan=true;
    char s1[102],s2[102],key[27],s3[102];
    int book[27]={0};
    int main()
    {
    scanf("%s %s",&s1,&s2);
    for(int i=0;i<strlen(s1);i++){key[s1[i]-'A']=s2[i];}
    for(int i=0;i<strlen(s2);i++){book[s2[i]-'A']=1;}
    for(int i=0;i<26;i++){if(book[i]==0){pan=false;break;}}
    scanf("%s",&s3);
    for(int i=0;i<strlen(s1);i++)
    for(int j=0;j<strlen(s1);j++)
    if(s1[i]==s1[j]&&s2[i]!=s2[j]){pan=false;break;}
    if(!pan)cout<<"Failed"<<endl;

    int len=strlen(s3);
    if(pan==true)
    {
    for(int i=0;i<strlen(s3);i++)
    {
    cout<<key[s3[i]-'A'];
    }
    }
    return 0;
    }//就是瞎搞 注意题设的大多数条件就可以了 逐一判断

  • 0
    @ 2014-11-03 22:16:04

    测试数据 #0: Accepted, time = 0 ms, mem = 532 KiB, score = 10

    测试数据 #1: Accepted, time = 0 ms, mem = 536 KiB, score = 10

    测试数据 #2: Accepted, time = 0 ms, mem = 532 KiB, score = 10

    测试数据 #3: Accepted, time = 0 ms, mem = 532 KiB, score = 10

    测试数据 #4: Accepted, time = 0 ms, mem = 540 KiB, score = 10

    测试数据 #5: Accepted, time = 0 ms, mem = 536 KiB, score = 10

    测试数据 #6: Accepted, time = 0 ms, mem = 532 KiB, score = 10

    测试数据 #7: Accepted, time = 0 ms, mem = 532 KiB, score = 10

    测试数据 #8: Accepted, time = 0 ms, mem = 536 KiB, score = 10

    测试数据 #9: Accepted, time = 0 ms, mem = 532 KiB, score = 10

    Accepted, time = 0 ms, mem = 540 KiB, score = 100

    C语言代码

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <stdbool.h>
    main()
    {
    bool pan=true;
    int b[26]={0},i,s=0;
    char s1[101],s2[101],a[26]={0};
    scanf("%s %s",s1,s2);
    for (i=0;i<strlen(s1);i++)
    {
    if (a[(s1[i])-'A']==0&&!b[(s2[i])-'A'])
    a[s1[i]-'A']=s2[i],s++,b[s2[i]-'A']=1;
    if (a[(s1[i])-'A']!=0&&a[(s1[i])-'A']!=s2[i]||a[(s1[i])-'A']==0&&b[(s2[i])-'A'])
    pan=false;
    }
    scanf("%s",s1);
    for (i=0;i<strlen(s1);i++)
    if (!a[(s1[i])-'A']||s<26)
    pan=false;
    if (pan)
    {
    for (i=0;i<strlen(s1);i++)
    printf("%c",a[(s1[i])-'A']);
    printf("\n");
    }
    else puts("Failed");
    return 0;
    }

  • 0
    @ 2014-10-15 19:24:40

    #include<cstring>
    #include<iostream>
    using namespace std;
    main()
    {
    bool b[26]={0};
    char a[26]={0};
    int i,s=0;
    string s1,s2;
    cin>>s1>>s2;
    for(i=0;i<s1.size();i++)
    {
    if(a[int(s1[i])-65]==0&&!b[int(s2[i])-65])
    {
    a[int(s1[i])-65]=s2[i];
    s++;
    b[int(s2[i])-65]=1;
    }
    if(a[int(s1[i])-65]!=0&&a[int(s1[i])-65]!=s2[i]||a[int(s1[i])-65]==0&&b[int(s2[i])-65])
    {
    cout<<"Failed";
    return 0;
    }
    }
    cin>>s1;
    for(i=0;i<s1.size();i++)
    if(!a[int(s1[i])-65]||s<26)
    {
    cout<<"Failed";
    return 0;
    }
    for(i=0;i<s1.size();i++)
    cout<<a[int(s1[i])-65];
    }

  • 0
    @ 2014-10-07 12:27:45

    var
    a:array['A'..'Z']of char;
    s1,s2,s3:ansistring;
    i:longint;c,d:char;
    begin
    fillchar(a,sizeof(a),'0');
    readln(s2);readln(s1);
    for i:=1 to length(s1)do
    if (a[s2[i]]<>'0')and(a[s2[i]]<>s1[i])then begin writeln('Failed');halt;end
    else a[s2[i]]:=s1[i];
    readln(s3);
    for c:='A'to 'Y'do for d:=chr(ord(c)+1)to 'Z'do if a[c]=a[d] then
    begin writeln('Failed');halt;end;
    for c:='A' to 'Z' do if a[c]='0'then begin writeln('Failed');halt;end;
    for i:=1 to length(S3)do write(a[s3[i]]);
    end.
    15ms水过

  • 0
    @ 2014-08-20 10:35:25

    数据略坑。。。题意略吊。。。
    var a:array['A'..'Z']of char;
    i,j:longint; ch:char;
    sa,sb,s,d,fax:ansistring;
    procedure kong(st1:ansistring; var st2:ansistring);
    var i:longint;
    begin
    st2:='';
    for i:=1 to length(st1) do
    if st1[i]<>' ' then st2:=st2+st1[i];
    end;

    procedure failed;
    begin
    writeln('Failed');
    halt;
    end;
    begin
    readln(fax); kong(fax,sa);
    readln(fax); kong(fax,sb);
    readln(fax); kong(fax,s);
    fillchar(a,sizeof(a),' ');
    for i:=1 to length(sb) do
    for j:=1 to length(sb) do
    if (sb[i]=sb[j])and(sa[i]<>sa[j]) then failed;
    for i:=1 to length(sa) do
    if (a[sa[i]]=' ') then a[sa[i]]:=sb[i]
    else if a[sa[i]]<>sb[i] then failed;
    for i:=1 to length(s) do
    if a[s[i]]<>' ' then d:=d+a[s[i]] else failed;
    for ch:='A' to 'Z' do
    if a[ch]=' ' then failed;
    writeln(d);

    end.

  • 0
    @ 2014-06-13 20:47:56

    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 280 KiB, score = 10

    测试数据 #1: Accepted, time = 15 ms, mem = 276 KiB, score = 10

    测试数据 #2: Accepted, time = 15 ms, mem = 280 KiB, score = 10

    测试数据 #3: Accepted, time = 0 ms, mem = 276 KiB, score = 10

    测试数据 #4: Accepted, time = 0 ms, mem = 276 KiB, score = 10

    测试数据 #5: Accepted, time = 15 ms, mem = 280 KiB, score = 10

    测试数据 #6: Accepted, time = 0 ms, mem = 280 KiB, score = 10

    测试数据 #7: Accepted, time = 31 ms, mem = 280 KiB, score = 10

    测试数据 #8: Accepted, time = 0 ms, mem = 280 KiB, score = 10

    测试数据 #9: Accepted, time = 15 ms, mem = 280 KiB, score = 10

    Accepted, time = 91 ms, mem = 280 KiB, score = 100

    代码

    #include<iostream>
    #include<cstring>
    using namespace std;
    string A,B,C;
    char d[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    int a[101],b[101],c[101],n,hash1[27],hash2[27];
    int main()
    {
    cin>>A>>B>>C;
    char A1[101],B1[101];
    n=A.size();
    if(n<26) {cout<<"Failed";return 0;}//如果输入文件字母数不到26个,就结束
    for(int i=1;i<=n;i++)
    {
    A1[i]=A[i-1];
    B1[i]=B[i-1];
    }
    for(int i=1;i<=n;i++)//A的值为65
    {
    a[i]=int(A1[i])-64;
    hash1[a[i]]=1;
    b[i]=int(B1[i])-64;
    hash2[b[i]]=1;
    }
    //如果没有都出现,就结束(题中说是加密文件,但如果加密文件中都出现了,原文件中没出现,也是不可能的)
    for(int i=1;i<=26;i++)
    if(hash2[i]==0) {cout<<"Failed";return 0;}
    for(int i=1;i<=26;i++)
    if(hash2[i]==0) {cout<<"Failed";return 0;}

    for(int i=1;i<=n;i++)
    {
    if(c[a[i]]!=0&&c[a[i]]!=b[i]) {cout<<"Failed";return 0;}//如果有不符合编码规则的,就结束
    c[a[i]]=b[i];
    }
    //如果都不是,就进行把新电报解密
    int m=C.size();
    for(int i=1;i<=m;i++)
    {
    int qwe;
    char qwe1;
    qwe1=C[i-1];
    qwe=int(qwe1)-64;
    cout<<d[c[qwe]-1];
    }
    return 0;
    }

  • 0
    @ 2014-04-24 22:33:07

    测试数据 #0: Accepted, time = 0 ms, mem = 500 KiB, score = 10

    测试数据 #1: Accepted, time = 0 ms, mem = 504 KiB, score = 10

    测试数据 #2: Accepted, time = 0 ms, mem = 496 KiB, score = 10

    测试数据 #3: Accepted, time = 0 ms, mem = 504 KiB, score = 10

    测试数据 #4: Accepted, time = 0 ms, mem = 500 KiB, score = 10

    测试数据 #5: Accepted, time = 15 ms, mem = 504 KiB, score = 10

    测试数据 #6: Accepted, time = 0 ms, mem = 496 KiB, score = 10

    测试数据 #7: Accepted, time = 0 ms, mem = 500 KiB, score = 10

    测试数据 #8: Accepted, time = 0 ms, mem = 500 KiB, score = 10

    测试数据 #9: Accepted, time = 0 ms, mem = 500 KiB, score = 10

    Accepted, time = 15 ms, mem = 504 KiB, score = 100

    代码

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <algorithm>
    #include <climits>
    #include <string>
    using namespace std;
    int i,j;
    bool flag[50],flagans=true,used[50];
    char trans[50],ans[1001],pd[50];
    string a,b,ques;
    #define trans(x) trans[x-(int)'A'+1]
    #define pd(x) pd[x-(int)'A'+1]
    #define flag(x) flag[x-(int)'A'+1]
    #define used(x) used[x-(int)'A'+1]
    int main()
    {
    memset(flag,false,sizeof(flag));
    memset(used,false,sizeof(used));
    cin>>a>>b>>ques;
    for(i=0;i<=a.length()-1;i++){
    if(((flag((int)a[i]))&&(b[i]!=trans((int)a[i])))||((used((int)b[i]))&&(a[i]!=pd((int)b[i])))){
    flagans=false;
    break;
    }
    trans((int)a[i])=b[i];
    flag((int)a[i])=true;
    pd((int)b[i])=a[i];
    used((int)b[i])=true;
    }
    for(i=1;i<=26;i++) if(!flag[i]) flagans=false;
    if(flagans){
    for(i=0;i<=ques.length()-1;i++) ans[i]=trans((int)ques[i]);
    cout<<ans;
    }
    else cout<<"Failed";
    system("pause");
    return 0;
    }

  • 0
    @ 2014-04-24 22:32:19

    测试数据 #0: Accepted, time = 0 ms, mem = 500 KiB, score = 10

    测试数据 #1: Accepted, time = 0 ms, mem = 504 KiB, score = 10

    测试数据 #2: Accepted, time = 0 ms, mem = 496 KiB, score = 10

    测试数据 #3: Accepted, time = 0 ms, mem = 504 KiB, score = 10

    测试数据 #4: Accepted, time = 0 ms, mem = 500 KiB, score = 10

    测试数据 #5: Accepted, time = 15 ms, mem = 504 KiB, score = 10

    测试数据 #6: Accepted, time = 0 ms, mem = 496 KiB, score = 10

    测试数据 #7: Accepted, time = 0 ms, mem = 500 KiB, score = 10

    测试数据 #8: Accepted, time = 0 ms, mem = 500 KiB, score = 10

    测试数据 #9: Accepted, time = 0 ms, mem = 500 KiB, score = 10

    Accepted, time = 15 ms, mem = 504 KiB, score = 100

    代码

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <algorithm>
    #include <climits>
    #include <string>
    using namespace std;
    int i,j;
    bool flag[50],flagans=true,used[50];
    char trans[50],ans[1001],pd[50];
    string a,b,ques;
    #define trans(x) trans[x-(int)'A'+1]
    #define pd(x) pd[x-(int)'A'+1]
    #define flag(x) flag[x-(int)'A'+1]
    #define used(x) used[x-(int)'A'+1]
    int main()
    {
    memset(flag,false,sizeof(flag));
    memset(used,false,sizeof(used));
    cin>>a>>b>>ques;
    for(i=0;i<=a.length()-1;i++){
    if(((flag((int)a[i]))&&(b[i]!=trans((int)a[i])))||((used((int)b[i]))&&(a[i]!=pd((int)b[i])))){
    flagans=false;
    break;
    }
    trans((int)a[i])=b[i];
    flag((int)a[i])=true;
    pd((int)b[i])=a[i];
    used((int)b[i])=true;
    }
    for(i=1;i<=26;i++) if(!flag[i]) flagans=false;
    if(flagans){
    for(i=0;i<=ques.length()-1;i++) ans[i]=trans((int)ques[i]);
    cout<<ans;
    }
    else cout<<"Failed";
    system("pause");
    return 0;
    }

  • 0
    @ 2013-10-25 21:34:46

    var
    ss,st,sd:string;
    a,f:array['A'..'Z'] of char;
    i:longint;
    procedure find;
    var
    i:longint;
    j:char;
    begin
    for j:='A' to 'Z' do begin a[j]:='0'; f[j]:='0'; end;
    for i:=1 to length(ss) do
    if a[ss[i]]='0' then
    begin
    a[ss[i]]:=st[i];
    if f[st[i]]='0' then f[st[i]]:=ss[i];
    if f[a[ss[i]]]<>ss[i] then begin writeln('Failed');halt;end;
    end
    else
    if (a[ss[i]]<>'0') and (st[i]<>a[ss[i]]) then begin writeln('Failed');halt;end;

    for j:='A' to 'Z' do
    if a[j]='0' then begin writeln('Failed');halt;end;
    end;
    begin
    readln(ss);
    readln(st);
    readln(sd);
    find;
    for i:=1 to length(sd) do
    write(a[sd[i]]);
    end.

    有好几个出错条件,开始第二个点就是过不了了。。 注意可能A-B 又出现 A-C

  • 0
    @ 2013-10-15 23:09:11

    #include <cstdio>
    #include <cstring>

    int main(void)
    {
    char enc[101], src[101], obj[101], key[26];
    bool flag[26], isfailed = 0;
    int len1, len2;

    memset(enc, 0, 101);
    memset(src, 0, 101);
    memset(obj, 0, 101);
    memset(key, 0, 26);
    memset(flag, 0, 26);

    scanf("%s%s%s", enc, src, obj);

    len1 = strlen(enc);
    len2 = strlen(obj);
    for (int i = 0; i < len1; ++i) {
    if (!flag[src[i] - 'A']) {
    key[enc[i] - 'A'] = src[i];
    flag[src[i] - 'A'] = 1;
    }
    else {
    if(key[enc[i] - 'A'] == src[i]) continue;
    else {
    isfailed = 1;
    break;
    }
    }
    }

    for (int i = 0; i < 26; ++i) {
    if (!flag[i]) {
    isfailed = 1;
    break;
    }
    }

    if (isfailed) printf("Failed");
    else
    for (int i = 0; i < len2; ++i) printf("%c", key[obj[i] - 'A']);
    return 0;
    }

  • 0
    @ 2012-10-31 20:25:30

    太水了

    本人一开始一直是第三个点过不去,后来才发现没有考虑‘不同字母对应不同密字’,WA了N次...大家一定要注意啊,认真读题,NOIP不过如此!

  • 0
    @ 2012-10-31 19:59:18

    编译通过...

    ├ 测试数据 01:答案正确... (0ms, 580KB)

    ├ 测试数据 02:答案正确... (0ms, 580KB)

    ├ 测试数据 03:答案正确... (0ms, 580KB)

    ├ 测试数据 04:答案正确... (0ms, 580KB)

    ├ 测试数据 05:答案正确... (0ms, 580KB)

    ├ 测试数据 06:答案正确... (0ms, 580KB)

    ├ 测试数据 07:答案正确... (0ms, 580KB)

    ├ 测试数据 08:答案正确... (0ms, 580KB)

    ├ 测试数据 09:答案正确... (0ms, 580KB)

    ├ 测试数据 10:答案正确... (0ms, 580KB)

    ---|---|---|---|---|---|---|---|-

    Accepted / 100 / 0ms / 580KB

    水题

  • -1
    @ 2016-11-17 15:04:56

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <vector>
    #include <cstdlib>
    #include <cstring>
    #include <map>

    using namespace std;

    string a,b,c;
    char m[300];
    int vis[300];

    void fail(){cout<<"Failed"<<endl;exit(0);}

    int main(){
    cin>>a>>b>>c;
    for(int i=0;a.c_str()[i];i++){
    if(m[a[i]]==0||m[a[i]]==b[i])
    m[a[i]]=b[i],vis[a[i]]=1;
    else fail();
    }
    for(int i='A';i<='Z';i++)if(!vis[i])fail();
    for(int i='A';i<='Z';i++)
    for(int j='A';j<='Z';j++)
    if(i!=j&&m[i]==m[j])fail();
    for(int i=0;c.c_str()[i];i++)cout<<m[c[i]];
    cout<<endl;
    }

信息

ID
1752
难度
5
分类
模拟 点击显示
标签
递交数
3159
已通过
1030
通过率
33%
被复制
11
上传者