//\\__ hr1212 __//\\
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 1000100
#define MOD 1000000007
int n,m,x,s[50][50],b[50][50];
string p;
void build(int a,int b,int c,int d){
int i,j;
x++;
if(p[x]=='p'){
build(a,(b+d)/2,(a+c)/2,d);
build(a,b,(a+c)/2,(b+d)/2);
build((a+c)/2,b,c,(b+d)/2);
build((a+c)/2,(b+d)/2,c,d);
}
else if(p[x]=='f'){
f(i,a,c)
f(j,b,d)
s[i][j]=1;
}
}
int main(){
int i,r,k,c=0,y=0,j,t,l,z,x1=0,y1=0;
ll ans=0;
si(t);
while(t--){
ans=0;
clr(s,0);
cin>>p;
x=-1;
build(0,0,32,32);
f(i,0,32)
f(j,0,32)
b[i][j]=s[i][j];
cin>>p;
x=-1;
build(0,0,32,32);
f(i,0,32)
f(j,0,32)
if(s[i][j] || b[i][j])
ans++;
printf("There are %d black pixels.\n",ans);
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 1000100
#define MOD 1000000007
int n,m,x,s[50][50],b[50][50];
string p;
void build(int a,int b,int c,int d){
int i,j;
x++;
if(p[x]=='p'){
build(a,(b+d)/2,(a+c)/2,d);
build(a,b,(a+c)/2,(b+d)/2);
build((a+c)/2,b,c,(b+d)/2);
build((a+c)/2,(b+d)/2,c,d);
}
else if(p[x]=='f'){
f(i,a,c)
f(j,b,d)
s[i][j]=1;
}
}
int main(){
int i,r,k,c=0,y=0,j,t,l,z,x1=0,y1=0;
ll ans=0;
si(t);
while(t--){
ans=0;
clr(s,0);
cin>>p;
x=-1;
build(0,0,32,32);
f(i,0,32)
f(j,0,32)
b[i][j]=s[i][j];
cin>>p;
x=-1;
build(0,0,32,32);
f(i,0,32)
f(j,0,32)
if(s[i][j] || b[i][j])
ans++;
printf("There are %d black pixels.\n",ans);
}
return 0;
}
No comments:
Post a Comment