1 solutions

  • 1
    @ 2022-8-19 17:42:41
    #include<iostream>
    #include<cstring>
    using namespace std;
    string a,b,w,ans;
    char h[26],g[26];
    int main(){
    	cin>>a>>b>>w;
    	int lena=a.length(),lenw=w.length();
    	for(int i=0;i<26;i++){
    		h[i]='*';
    		g[i]='*';
    	}
    	for(int i=0;i<lena;i++){
    		if(h[a[i]-'A']=='*')
    			h[a[i]-'A']=b[i];
    		if(('A'<=h[a[i]-'A']&&'Z'>=h[a[i]-'A'])&&(h[a[i]-'A']!=b[i])){
    			cout<<"Failed"<<endl;
    			return 0;
    		}
    		if(g[b[i]-'A']=='*')
    			g[b[i]-'A']=a[i];
    		if(('A'<=g[b[i]-'A']&&'Z'>=g[b[i]-'A'])&&(g[b[i]-'A']!=a[i])){
    			cout<<"Failed"<<endl;
    			return 0;
    		}
    	}
    	for(int i=0;i<26;i++){
    		if(h[i]=='*'){
    			cout<<"Failed"<<endl;
    			return 0;
    		}
    	}
    	for(int i=0;i<lenw;i++)
    		cout<<h[w[i]-'A'];
    	return 0;
    }
    
    • 1

    Information

    ID
    24
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    6
    Tags
    # Submissions
    20
    Accepted
    12
    Uploaded By