結果
| 問題 | No.3249 AND | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-08-29 22:25:25 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 1,243 bytes | 
| コンパイル時間 | 2,584 ms | 
| コンパイル使用メモリ | 276,268 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-08-29 23:59:48 | 
| 合計ジャッジ時間 | 4,074 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 20 WA * 1 | 
ソースコード
#include <bits/stdc++.h>
[[nodiscard]] static inline constexpr int_fast32_t solve(const uint_fast32_t n, const std::vector<uint_least32_t>& b) noexcept
{
	uint_fast32_t possibility[2] = { UINT_FAST32_MAX, UINT_FAST32_MAX };
	for (uint_fast32_t i = 1; i <= n; ++i)
		for (uint_fast32_t j = 0; j != 30; ++j)
		{
			if ((b[i] >> j) & 1)
			{
				if (!((i >> j) & 1)) [[unlikely]]
					return -1;
				else if ((possibility[0] >> j) & 1) [[unlikely]]
					possibility[0] ^= UINT32_C(1) << j;
			}
			else
			{
				if (((i >> j) & 1) && ((possibility[1] >> j) & 1)) [[unlikely]]
					possibility[1] ^= UINT32_C(1) << j;
			}
		}
	uint_fast32_t ans = 0;
	for (uint_fast32_t j = 0; j != 30; ++j)
	{
		if ((possibility[0] >> j) & 1) continue;
		else if ((possibility[1] >> j) & 1) ans |= UINT32_C(1) << j;
		else return -1;
	}
	// if (ans == 0)
	// 	for (uint_fast32_t j = 0; j != 30; ++j)
	// 		if ((possibility[1] >> j) & 1)
	// 		{
	// 			ans = UINT32_C(1) << j;
	// 			break;
	// 		}
	return ans;
}
int main()
{
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	
	uint_fast32_t n, i;
	std::cin >> n;
	std::vector<uint_least32_t> b(n + 1);
	for (i = 1; i <= n; ++i)
		std::cin >> b[i];
	std::cout << solve(n, b) << '\n';
	return 0;
}
            
            
            
        