結果

問題 No.669 対決!!! 飲み比べ
ユーザー AC2KAC2K
提出日時 2023-04-26 22:49:17
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,888 bytes
コンパイル時間 2,388 ms
コンパイル使用メモリ 246,732 KB
実行使用メモリ 11,512 KB
最終ジャッジ日時 2024-04-27 23:25:09
合計ジャッジ時間 3,515 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,532 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 3 ms
7,940 KB
testcase_04 AC 13 ms
9,064 KB
testcase_05 AC 14 ms
10,976 KB
testcase_06 WA -
testcase_07 AC 2 ms
7,512 KB
testcase_08 AC 6 ms
8,052 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 3 ms
7,908 KB
testcase_11 AC 9 ms
9,692 KB
testcase_12 AC 7 ms
8,672 KB
testcase_13 AC 2 ms
7,900 KB
testcase_14 AC 3 ms
7,528 KB
testcase_15 AC 14 ms
8,668 KB
testcase_16 AC 8 ms
8,804 KB
testcase_17 AC 6 ms
7,900 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 12 ms
9,440 KB
testcase_20 AC 5 ms
8,720 KB
testcase_21 AC 4 ms
8,176 KB
testcase_22 AC 2 ms
8,080 KB
testcase_23 AC 6 ms
8,800 KB
testcase_24 AC 3 ms
7,652 KB
testcase_25 AC 3 ms
7,704 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 3 ms
7,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 2 "library/src/template.hpp"
#include<bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(x) (x).begin(),(x).end()
#define popcount(x) __builtin_popcount(x)
using i128=__int128_t;
using ll = long long;
using ld = long double;
using graph = std::vector<std::vector<int>>;
using P = std::pair<int, int>;
constexpr int inf = 1e9;
constexpr ll infl = 1e18;
constexpr ld eps = 1e-6;
const long double pi = acos(-1);
constexpr uint64_t MOD = 1e9 + 7;
constexpr uint64_t MOD2 = 998244353;
constexpr int dx[] = { 1,0,-1,0 };
constexpr int dy[] = { 0,1,0,-1 };
template<class T>constexpr inline void chmax(T&x,T y){if(x<y)x=y;}
template<class T>constexpr inline void chmin(T&x,T y){if(x>y)x=y;}
#line 3 "library/src/data-structure/hash_map.hpp"
namespace kyopro {
/// @brief HashMap
template <typename Key,
          typename Val,
          uint32_t n = 1 << 20,
          Val default_val = Val()>
class hash_map {
    using u32 = uint32_t;
    using u64 = uint64_t;

    u64* flag = new u64[n];
    Key* keys = new Key[n];
    Val* vals = new Val[n];

    static constexpr u32 shift = 64 - std::__lg(n);

    u64 r;
    inline u32 get_hash(const Key& k) const { return ((u64)k * r) >> shift; }

    static constexpr uint8_t mod_msk = (1 << 6) - 1;

public:
    explicit constexpr hash_map() {
        r = std::chrono::steady_clock::now().time_since_epoch().count();
        r ^= r >> 16;
        r ^= r << 32;
    }
    Val& operator[](const Key& k) {
        u32 hash = get_hash(k);

        while (1) {
            if (!(flag[hash >> 6] &
                  (static_cast<u64>(1) << (hash & mod_msk)))) {
                keys[hash] = k;
                flag[hash >> 6] |= static_cast<u64>(1) << (hash & mod_msk);
                return vals[hash] = default_val;
            }

            if (keys[hash] == k) return vals[hash];
            hash = (hash + 1) & (n - 1);
        }
    }

    Val* find(const Key& k) const {
        u32 hash = get_hash(k);
        while (1) {
            if (!(flag[hash >> 6] & (static_cast<u64>(1) << (hash & mod_msk))))
                return nullptr;
            if (keys[hash] == k) return &(vals[hash]);
            hash = (hash + 1) & (n - 1);
        }
    }
};
};  // namespace kyopro
#line 3 "main.cpp"
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    int grundy[1000001];
    kyopro::hash_map<int, int> transition;

    grundy[0] = 0;
    for (int i = 1; i <= 10000; ++i) {
        if (i - k - 1 >= 0) --transition[grundy[i - k - 1]];
        ++transition[grundy[i - 1]];
        int mex = 0;
        while (1){
            auto ptr = transition.find(mex);
            if (!ptr || !*ptr) break;
            else ++mex;
        }
        grundy[i] = mex;
    }

    int XOR_SUM = 0;
    rep(i, n) {
        int a;
        cin>>a;
        XOR_SUM ^= grundy[a];
    }

    puts(XOR_SUM ? "YES" : "NO");
}
0