LOADING

加载过慢请开启缓存,浏览器默认开启

daily 2

2023/8/6 daily

CF 208B

void solve() {
  vector<int> st;
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  // reverse order
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    while (st.size() && a[st.back()] < a[i]) st.pop_back();
    if (st.size()) {
      ans = max(ans, a[st.back()] ^ a[i]);
    }
    st.push_back(i);
  }
  // non-reverse order
  for (int i = n; i >= 1; --i) {
    while (st.size() && a[st.back()] < a[i]) st.pop_back();
    if (st.size()) {
      ans = max(ans, a[st.back()] ^ a[i]);
    }
    st.push_back(i);
  }
  cout << ans << '\n';
  return;
}

CF 1394A