結果
問題 | No.669 対決!!! 飲み比べ |
ユーザー |
|
提出日時 | 2024-05-19 23:12:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 95 ms / 2,000 ms |
コード長 | 944 bytes |
コンパイル時間 | 846 ms |
コンパイル使用メモリ | 84,628 KB |
最終ジャッジ日時 | 2025-02-21 16:10:29 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 |
ソースコード
#include <iostream>#include <vector>#include <utility>#include <set>#include <algorithm>using namespace std;using ll = long long;#define rep(i,N) for(int i=0;i<(int)N;++i)#define MAX 1000009#define MAXK 1009vector<int> DP(MAX);int main(void) {int N, K; cin >> N >> K;vector<int> A(N);rep(i, N) cin >> A[i];//step1 DPでgrundy数を求めるset<int> st;rep(i, MAXK) st.insert(i);//-1から-Kまでの間のgrundy数をメモするvector<int> cnt(MAXK, 0);DP[0] = 0;st.erase(0);cnt[0] = 1;for (int i = 1; i < MAX; ++i) {if (i - K > 0) {cnt[DP[i - K - 1]]--;if (cnt[DP[i - K - 1]] == 0) st.insert(DP[i - K - 1]);}auto itr = st.begin();DP[i] = *itr;st.erase(DP[i]);cnt[DP[i]]++;}//rep(i, 1000) cout << DP[i] << " ";//step2 grundy数からXORするint grundy = 0;rep(i, N) grundy ^= DP[A[i]];if (grundy == 0) cout << "NO" << endl;else cout << "YES" << endl;return 0;}