結果

問題 No.3550 Another Rurumaru Function Problem
コンテスト
ユーザー tnakao0123
提出日時 2026-05-23 18:39:58
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 1,229 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 618 ms
コンパイル使用メモリ 70,272 KB
実行使用メモリ 6,668 KB
最終ジャッジ日時 2026-05-23 18:40:04
合計ジャッジ時間 4,720 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 3550.cc:  No.3550 Another Rurumaru Function Problem - yukicoder
 */

#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 200000;
const int BN = 30;

/* typedef */

using vi = vector<int>;

/* global variables */

int as[MAX_N];

/* subroutines */

int f(int x, int y) {
  int s = 0;
  for (int i = 0; i < BN && (x > 0 || y > 0); i++, x >>= 1, y >>= 1) {
    int bx = x & 1, by = y & 1;
    s |= (! (i & 1) ? (bx & by) : (bx | by)) << i;
  }
  return s;
}

void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  vi av(as, as + n);

  int x = 0, omsk = 0;
  for (int i = BN - 1, bi = 1 << i; i >= 0; i--, bi >>= 1) {
    if (! (i & 1)) { // i:even -> AND
      vi av1;
      int ao = 0;
      for (auto a: av) {
	if (a & bi) av1.push_back(a), ao |= (a & omsk);
      }
      if (! av1.empty() && (ao & omsk) == omsk) {
	x |= bi;
	swap(av, av1);
      }
    }
    else { // i:odd -> OR
      int bo = 0;
      for (auto a: av) bo |= (a & bi);
      if (bo) {
	x |= bi;
	omsk |= bi;
      }
    }
  }

  printf("%d\n", x);
  
  return 0;
}

0