比赛 期末考试0 评测结果 AWWWWWWWWW
题目名称 学姐的下午茶 最终得分 10
用户昵称 LikableP 运行时间 0.013 s
代码语言 C++ 内存使用 1.63 MiB
提交时间 2026-02-07 11:07:21
显示代码纯文本
#include <cstdio>
#include <cstring>

int n;
char str[110];

struct NODE {
  int child0 = 0, child1 = 0;
} node[2010];
int root = 1, nodeNum = 1;

void Insert(int len) {
  int now = root;
  for (int i = 1; i <= len; ++i) {
    if (str[i] == '0') {
      if (!node[now].child0) node[now].child0 = ++nodeNum;
      now = node[now].child0;
    } else if (str[i] == '1') {
      if (!node[now].child1) node[now].child1 = ++nodeNum;
      now = node[now].child1;
    } else {
      
    }
  }
}

int main() {
  #ifdef LOCAL
    freopen("!input.in", "r", stdin);
    freopen("!output.out", "w", stdout);
  #else
    freopen("lowtea.in", "r", stdin);
    freopen("lowtea.out", "w", stdout);
  #endif
  
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", str + 1);
    Insert(strlen(str + 1));
  }
  printf("%d\n", nodeNum);
  return 0;
}