結果
問題 |
No.3249 AND
|
ユーザー |
|
提出日時 | 2025-08-30 08:40:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 1,888 bytes |
コンパイル時間 | 1,822 ms |
コンパイル使用メモリ | 194,256 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-05 11:41:27 |
合計ジャッジ時間 | 3,101 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 23 |
コンパイルメッセージ
main.cpp:48:15: warning: extra tokens at end of #undef directive 48 | #undef getchar() | ^
ソースコード
#include <bits/stdc++.h> #define fp(i, a, b) for (int i(a), ed(b); i <= ed; ++i) #define fb(i, a, b) for (int i(a), ed(b); i >= ed; --i) #define go(u, i) for (int i(head[u]); i; i = e[i].nxt) using namespace std; typedef long long Int; typedef pair<int, int> pii; //////////////////////////////////////////////////////////////////////////////////////////////////// template <typename T1, typename T2> inline void chkmin(T1& a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chkmax(T1& a, T2 b) { if (a < b) a = b; } namespace FastIO { char buf[1 << 21], *p1 = buf, *p2 = buf; #define getchar() (p1 == p2 && (p1 = buf, p2 = (p1 + fread(buf, 1, 1 << 21, stdin))) == p1 ? EOF : *p1++) template <typename T> inline T read() { T x = 0, w = 0; char ch = getchar(); while (ch < '0' || ch > '9') w |= (ch == '-'), ch = getchar(); while ('0' <= ch && ch <= '9') x = x * 10 + (ch ^ '0'), ch = getchar(); return w ? -x : x; } template <typename T> inline void write(T x) { if (!x) return; write<T>(x / 10), putchar((x % 10) ^ '0'); } template <typename T> inline void print(T x) { if (x > 0) write<T>(x); else if (x < 0) putchar('-'), write<T>(-x); else putchar('0'); } template <typename T> inline void print(T x, char en) { print<T>(x), putchar(en); } }; // namespace FastIO using namespace FastIO; #undef getchar() const int maxn = 2e5 + 10, maxm = 20, mod = 998244353; int n, b[maxn]; int main() { n = FastIO::read<int>(); fp(i, 1, n) b[i] = FastIO::read<int>(); int ans = 0; fp(i, 1, n) ans |= b[i]; if (!ans) { ans = 1; while (1) { ans *= 2; if (ans > n) break; } } fp(i, 1, n) { if ((i & ans) != b[i]) { ans = -1; break; } } cout << ans << "\n"; return 0; }