結果
問題 | No.184 たのしい排他的論理和(HARD) |
ユーザー |
![]() |
提出日時 | 2019-10-15 20:13:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 54 ms / 5,000 ms |
コード長 | 801 bytes |
コンパイル時間 | 1,218 ms |
コンパイル使用メモリ | 160,292 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 12:32:28 |
合計ジャッジ時間 | 3,448 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | REP(i, n) scanf("%lld", &a[i]); | ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include "bits/stdc++.h" #define REP(i, n) for(int i = 0; i < int(n); i++) #define FOR(i,n,m) for(int i = int(n); i < int(m); i++) using namespace std; typedef long long ll; const int MOD = 1e9 + 7; const int INF = 1e9 + 6; const ll LLINF = 1e18 + 1; int main() { int n; cin >> n; vector<ll> a(n); REP(i, n) scanf("%lld", &a[i]); int cnt = 0; REP(i, n) { // 最大でも60回程度しかならないからO(NM) if (a[i] == 0) { continue; } cnt++; int x = 0; while ((1LL << (x+1)) <= a[i]) x++; //cout << i << " " << x << " " << cnt << endl; FOR(j, i+1, n) { if ((1LL << x) & a[j]) { a[j] ^= a[i]; } } } cout << (1LL << cnt) << endl; return 0; }