結果
問題 | No.715 集合と二人ゲーム |
ユーザー |
|
提出日時 | 2018-07-13 23:19:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,971 bytes |
コンパイル時間 | 2,143 ms |
コンパイル使用メモリ | 200,948 KB |
最終ジャッジ日時 | 2025-01-06 12:01:13 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 WA * 23 TLE * 15 |
ソースコード
#include <bits/stdc++.h>#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= int(m); -- (i))#define ALL(x) begin(x), end(x)using namespace std;template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }template <class T> inline void chmin(T & a, T const & b) { a = min(a, b); }template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, int(xs.size()) - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }int main() {// inputint n; cin >> n;vector<int> a(n);REP (i, n) cin >> a[i];// solvesort(ALL(a));a.erase(unique(ALL(a)), a.end());n = a.size();vector<int> b;for (int l = 0; l < n; ) {int r = l + 1;while (r < n and a[r] == a[r - 1] + 1) {++ r;}b.push_back(r - l);l = r;}int max_b = *max_element(ALL(b));vector<int> grundy(max_b + 1);grundy[0] = 0;REP3 (i, 1, max_b + 1) {vector<int> used;REP (l, i) {int r = i - l - 1;used.push_back(grundy[l] ^ grundy[r]);}sort(ALL(used));int & g = grundy[i];while (g < used.size() and g == used[g]) {++ g;}}int answer = 0;for (int b_i : b) {answer ^= grundy[b_i];}// outputcout << (answer ? "First" : "Second") << endl;return 0;}