結果
問題 | No.183 たのしい排他的論理和(EASY) |
ユーザー |
|
提出日時 | 2015-04-17 21:07:13 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 144 ms / 5,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 513 ms |
コンパイル使用メモリ | 65,884 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-29 01:46:58 |
合計ジャッジ時間 | 1,933 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include<iostream> #include<queue> #include<numeric> using namespace std; const int VAL = 5005; const int RANGE = (1 << 15) + 5; int nVal, val[VAL]; void read() { cin >> nVal; for (int i = 0; i < nVal; ++i) cin >> val[i]; } void work() { bool visited[RANGE] = {}; queue<int> Q; visited[0] = true; Q.push(0); while (!Q.empty()) { int cur = Q.front(); Q.pop(); for (int i = 0; i < nVal; ++i) { int nex = cur ^ val[i]; if (!visited[nex]) { visited[nex] = true; Q.push(nex); } } } cout << accumulate(visited, visited + RANGE, 0) << endl; } int main() { read(); work(); return 0; }