zoukankan      html  css  js  c++  java
  • hdu3791 搜索二叉树 (最基本的树)

    View Code
     1 #include<stdio.h>
     2 #include<string.h>
     3 int tree[1050];
     4 int tree1[1050];
     5 char s[12];
     6 int main()
     7 {
     8     int t,i;
     9     while(scanf("%d",&t),t)
    10     {
    11         scanf("%s",s);
    12         memset(tree,-1,sizeof(tree));
    13         for(i=0;s[i];i++)
    14         {
    15             int c=s[i]-'0';
    16             int j=1;
    17             while(tree[j]!=-1)
    18             {
    19                 if(c<tree[j])
    20                 j=j*2;
    21                 else
    22                 j=j*2+1;
    23             }
    24             tree[j]=c;
    25         }
    26         while(t--)
    27         {
    28             scanf("%s",s);
    29             memset(tree1,-1,sizeof(tree1));
    30             for(i=0;s[i];i++)
    31             {
    32                 int c=s[i]-'0';
    33                int j=1;
    34                 while(tree1[j]!=-1)
    35                 {
    36                     if(c<tree1[j])
    37                     j=j*2;
    38                     else j=j*2+1;
    39                 }
    40                 tree1[j]=c;
    41             }
    42             for(i=1;i<1024&&tree[i]==tree1[i];i++);
    43             if(i==1024)printf("YES\n");
    44             else printf("NO\n");
    45         }
    46     }
    47     return 0;
    48 
    49 }
  • 相关阅读:
    c# 遮罩
    判断当前task中的运行的activity是否为当前应用
    Chrome+SwitchySharp+myentunnel+SSH
    vps
    系统制作
    vs2010 mfc
    android ndk
    乐 Phone刷机教程(全过程)
    mysql 保留字 冲突
    mysql 存储过程
  • 原文地址:https://www.cnblogs.com/ACshasow/p/2751617.html
Copyright © 2011-2022 走看看