結果
問題 |
No.3249 AND
|
ユーザー |
![]() |
提出日時 | 2025-09-01 14:16:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 662 bytes |
コンパイル時間 | 490 ms |
コンパイル使用メモリ | 41,924 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-01 14:16:04 |
合計ジャッジ時間 | 2,537 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:28:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | for (int i = 1; i <= n; i++) scanf("%d", bs + i); | ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3249.cc: No.3249 AND - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 1000000; /* typedef */ /* global variables */ int bs[MAX_N + 1]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", bs + i); int x = 0; for (int i = 1; i <= n; i++) x |= bs[i]; for (int i = 1; i <= n; i++) { if ((bs[i] & i) != bs[i]) { puts("-1"); return 0; } x &= (~i | bs[i]); } bool f = true; for (int i = 1; f && i <= n; i++) f = (bs[i] == (i & x)); printf("%d\n", f ? x : -1); return 0; }