mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
43 lines
559 B
C++
43 lines
559 B
C++
|
#include <cstdio>
|
||
|
#include <cstring>
|
||
|
#include <cstdlib>
|
||
|
#include <algorithm>
|
||
|
using namespace std;
|
||
|
|
||
|
struct btree
|
||
|
{
|
||
|
btree* l;
|
||
|
btree* r;
|
||
|
char v;
|
||
|
};
|
||
|
|
||
|
btree _node;
|
||
|
btree* root=&_node;
|
||
|
|
||
|
int counter=0;
|
||
|
|
||
|
void deal(btree* n)
|
||
|
{
|
||
|
scanf("%c",&n->v);
|
||
|
if(n->v=='#')
|
||
|
{
|
||
|
n->l=n->r=NULL;
|
||
|
return ;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
n->l=new btree;
|
||
|
deal(n->l);
|
||
|
n->r=new btree;
|
||
|
deal(n->r);
|
||
|
if(n->l->v=='#'&&n->r->v=='#') ++counter;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
deal(root);
|
||
|
printf("%d\n",counter);
|
||
|
return 0;
|
||
|
}
|