#include <iostream>
#include <string>
using namespace std;
int mapp(char c){
switch (c){
case 'V':return 0;
case 'U':return 1;
case 'C':return 2;
default :return 3;
}
}
char mapp(int i){
switch (i){
case 0:return 'V';
case 1:return 'U';
case 2:return 'C';
default: return 'D';
}
}
int ctod(string s){
int ans=0,tmp=1;
for(int i=s.size()-1;i>=0;i--){
ans+=tmp*mapp(s[i]);
tmp<<=2;
}
return ans;
}
int main(){
ios::sync_with_stdio(0);
int t;
cin>>t;
cout<<"COWCULATIONS OUTPUT"<<endl;
while(t--){
string n1,n2;
cin>>n1>>n2;
int num1=ctod(n1),num2=ctod(n2);
for(int i=0;i<3;i++){
char c;
cin>>c;
if(c=='A')
num2+=num1;
else if(c=='R')
num2>>=2;
else if(c=='L')
num2<<=2;
}
string s;
cin>>s;
if(ctod(s)==(num2))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
cout<<"END OF OUTPUT"<<endl;
}
#include <string>
using namespace std;
int mapp(char c){
switch (c){
case 'V':return 0;
case 'U':return 1;
case 'C':return 2;
default :return 3;
}
}
char mapp(int i){
switch (i){
case 0:return 'V';
case 1:return 'U';
case 2:return 'C';
default: return 'D';
}
}
int ctod(string s){
int ans=0,tmp=1;
for(int i=s.size()-1;i>=0;i--){
ans+=tmp*mapp(s[i]);
tmp<<=2;
}
return ans;
}
int main(){
ios::sync_with_stdio(0);
int t;
cin>>t;
cout<<"COWCULATIONS OUTPUT"<<endl;
while(t--){
string n1,n2;
cin>>n1>>n2;
int num1=ctod(n1),num2=ctod(n2);
for(int i=0;i<3;i++){
char c;
cin>>c;
if(c=='A')
num2+=num1;
else if(c=='R')
num2>>=2;
else if(c=='L')
num2<<=2;
}
string s;
cin>>s;
if(ctod(s)==(num2))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
cout<<"END OF OUTPUT"<<endl;
}
Comments
Post a Comment