結果
問題 | No.24 数当てゲーム |
ユーザー |
|
提出日時 | 2016-02-09 00:07:41 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 973 bytes |
コンパイル時間 | 462 ms |
コンパイル使用メモリ | 55,692 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 21:51:16 |
合計ジャッジ時間 | 1,128 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <cstdlib>#include <array>#include <iostream>#ifdef __GNUC__# define popcnt(n) __builtin_popcount(n)#elsestatic unsigned intpopcnt(unsigned int n){unsigned int cnt = 0;while (n != 0) {cnt += (n & 0x01);n >>= 1;}}#endifstd::size_tbsf(unsigned int n){for (std::size_t i = 0, len = sizeof(n) * 3; i < len; i++, n >>= 1) {if ((n & 0x01) == 0x01) {return i;}}return -1;}static const int MASK = 0x03ff;intmain(){std::cin.tie(0);std::ios::sync_with_stdio(false);int n;std::cin >> n;int candidateBit = MASK;for (int i = 0; popcnt(candidateBit) != 1 && i < n; i++) {std::array<int, 4> ns;std::string result;std::cin >> ns[0] >> ns[1] >> ns[2] >> ns[3] >> result;int n = ((1 << ns[0]) | (1 << ns[1]) | (1 << ns[2]) | (1 << ns[3]));candidateBit &= result == "YES" ? n : (~n & MASK);}std::cout << bsf(candidateBit) << std::endl;return EXIT_SUCCESS;}