记录编号 601508 评测结果 ATATAAAAAA
题目名称 2980.绝世好题 最终得分 80
用户昵称 GravatarLikableP 是否通过 未通过
代码语言 C++ 运行时间 4.019 s
提交时间 2025-06-25 16:39:57 内存使用 1.50 MiB
显示代码纯文本
#include <algorithm>
#include <cstdio>
#define isdigit(ch) ((ch) >= '0' && (ch) <= '9')

namespace IO {
template <typename T>
T read() {
  T res = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-')
      f = -1;
  for (; isdigit(ch); ch = getchar())
    res = (res << 3) + (res << 1) + (ch ^ 48);
  return res * f;
}

template <typename T>
void write(T x, char ed = '\n') {
  if (x < 0)
    x = -x, putchar('-');
  static int sta[sizeof(T) << 2], top = 0;
  do {
    sta[++top] = x % 10;
    x /= 10;
  } while (x);
  while (top) {
    putchar(sta[top--] ^ 48);
  }
  putchar(ed);
}
} // namespace IO
using namespace ::IO;

const int MAXN = 1e5 + 10;

int n;
int a[MAXN];
int f[MAXN]; // f[i] : 以 i 结尾的最长子序列长度
int ans = -1;

int main() {
  freopen("bzoj_4300.in", "r", stdin);
  freopen("bzoj_4300.out", "w", stdout);
  n = read<int>();
  for (int i = 1; i <= n; ++i) {
    a[i] = read<int>();
  }

  f[1] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= i - 1; ++j) {
      if (a[i] & a[j]) {
        f[i] = ::std::max(f[i], f[j] + 1);
      }
    }
    ans = ::std::max(ans, f[i]);
  }

  write(ans);
  return 0;
}