## Cifer

~~~题目链接～～

code：


#include <iostream>
using namespace std;

typedef struct node
{
char ch;
struct node *nt[4];
}Node;

int ans = 0;

void build(int &cur, Node *r, string &s)
{
int flag = 0;
r->ch = s[cur++];
for(int j = 0; j<4 && cur<s.size(); j++)
{
r->nt[j] = new Node;
if(s[cur] == 'p')
{
build(cur, r->nt[j], s);
continue;
}
r->nt[j]->ch = s[cur++];
}
}

void query(Node *r1, Node *r2, int cur)
{
if(r1->ch == 'p' && r2->ch == 'p')
for(int i = 0; i<4; i++)
query(r1->nt[i], r2->nt[i], cur*2);
else if(r1->ch == 'f' || r2->ch == 'f')
ans += (32/cur)*(32/cur);
else if(r1->ch == 'e' && r2->ch == 'p')
for(int i = 0; i<4; i++)
query(r1, r2->nt[i], cur*2);
else if(r1->ch == 'p' && r2->ch == 'e')
for(int i = 0; i<4; i++)
query(r1->nt[i], r2, cur*2);
}

int main()
{
int t = 0, cur = 0;
string s1, s2;
cin>>t;
while(t--)
{
cin>>s1>>s2;
ans = 0;
Node *r1 = new Node;
Node *r2 = new Node;
cur = 0;
build(cur, r1, s1);
cur = 0;
build(cur, r2, s2);
query(r1, r2, 1);
cout<<"There are "<<ans<<" black pixels."<<endl;
}
return 0;
}



2013-10-15 01:44:28

2015-07-31 16:17:17

2016-12-23 14:10:17

2013-07-26 21:34:03

2014-07-31 18:25:17

2016-05-17 10:20:46

2017-04-19 15:53:31

2013-04-19 15:35:04