結果
| 問題 | No.183 たのしい排他的論理和(EASY) |
| コンテスト | |
| ユーザー |
hanorver
|
| 提出日時 | 2015-11-12 18:47:52 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
不安定
|
| 実行時間 | 91 ms / 5,000 ms |
| + 401µs | |
| コード長 | 588 bytes |
| 記録 | |
| コンパイル時間 | 351 ms |
| コンパイル使用メモリ | 82,356 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-08-01 17:27:00 |
| 合計ジャッジ時間 | 2,192 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include<iostream>
#include<vector>
#include<set>
#include<numeric>
int main() {
int switches;
std::cin >> switches;
std::set<int> s;
for (int i = 0; i < switches;i++){
int num;
std::cin >> num;
s.insert(num);
}
// 排他的論理和は%で置き換えることができる
bool ans[32768] = {false};
ans[0] = true;
for (std::set<int>::iterator it = s.begin(); it != s.end(); ++it) {
for (int j = 0; j < 32768; j++) {
if(ans[j]) ans[j ^ *it] = true;
}
}
int a = 0;
for (int i = 0; i < 32768; i++) {
a += ans[i];
}
std::cout << a << std::endl;
return 0;
}
hanorver