結果

問題 No.2619 Sorted Nim
コンテスト
ユーザー fura
提出日時 2026-10-08 03:09:37
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 10 ms / 2,000 ms
+ 642µs
コード長 4,669 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,475 ms
コンパイル使用メモリ 340,616 KB
実行使用メモリ 9,900 KB
最終ジャッジ日時 2026-10-08 03:09:48
合計ジャッジ時間 9,644 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 62
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// https://github.com/fura2/cp-library

#include <bits/stdc++.h>

#ifdef LOCAL
#include <template/debug.hpp>
#else
#define show(...) ((void)0)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif


inline constexpr int INF = 700'000'000;
inline constexpr long long LINF = 3'000'000'000'000'000'000LL;
inline constexpr double DINF = 1e100;


template <typename T>
struct Input {
  static T read() {
    T x;
    std::cin >> x;
    return x;
  }
};

template <typename T, typename U>
struct Input<std::pair<T, U>> {
  static std::pair<T, U> read() {
    return std::pair{Input<T>::read(), Input<U>::read()};
  }
};

template <typename T>
struct Input<std::vector<T>> {
  static std::vector<T> read(int n) {
    std::vector<T> v;
    v.reserve(n);
    for (int i = 0; i < n; ++i) {
      v.push_back(Input<T>::read());
    }
    return v;
  }

  static std::vector<T> read(int n, int offset) {
    std::vector<T> v;
    v.reserve(n);
    for (int i = 0; i < n; ++i) {
      v.push_back(Input<T>::read() - offset);
    }
    return v;
  }
};

template <typename T, typename... Args>
T input(Args&&... args) {
  return Input<T>::read(std::forward<Args>(args)...);
}

template <typename T>
struct Output {
  static void write(const T& x) { std::cout << x; }
};

template <typename T, typename U>
struct Output<std::pair<T, U>> {
  static void write(const std::pair<T, U>& p) {
    Output<T>::write(p.first);
    std::cout << " ";
    Output<U>::write(p.second);
  }
};

template <typename T, std::size_t N>
struct Output<T[N]> {
  static void write(const T (&a)[N]) {
    for (int i = 0; const auto& x: a) {
      if (i > 0) std::cout << " ";
      Output<T>::write(x);
      ++i;
    }
  }

  static void write(const T (&a)[N], int offset)
    requires requires(const T& x, int n) { x + n; }
  {
    for (int i = 0; const auto& x: a) {
      if (i > 0) std::cout << " ";
      Output<T>::write(x + offset);
      ++i;
    }
  }
};

template <typename T>
struct Output<std::vector<T>> {
  static void write(const std::vector<T>& v) {
    for (int i = 0; const auto& x: v) {
      if (i > 0) std::cout << " ";
      Output<T>::write(x);
      ++i;
    }
  }

  static void write(const std::vector<T>& v, int offset)
    requires requires(const T& x, int n) { x + n; }
  {
    for (int i = 0; const auto& x: v) {
      if (i > 0) std::cout << " ";
      Output<T>::write(x + offset);
      ++i;
    }
  }
};

template <typename T, typename... Args>
void output(const T& x, Args&&... args) {
  Output<T>::write(x, std::forward<Args>(args)...);
#ifdef LOCAL
  std::cout << std::endl;
#else
  std::cout << "\n";
#endif
}

inline void output(const char* s) { output<const char*>(s); }

#define impl_overload4(a, b, c, d, e, ...) e

// clang-format off
#define impl_rep4(i, a, b, c) for (int i = (a); i < (b); i += (c))
#define impl_rep3(i, a, b) impl_rep4(i, a, b, 1)
#define impl_rep2(i, n) impl_rep3(i, 0, n)
#define impl_rep1(n) for (int _ = 0; _ < (n); ++_)
#define rep(...) impl_overload4(__VA_ARGS__, impl_rep4, impl_rep3, impl_rep2, impl_rep1)(__VA_ARGS__)

#define impl_rrep4(i, a, b, c) for (int i = (b) - 1; i >= (a); i -= (c))
#define impl_rrep3(i, a, b) impl_rrep4(i, a, b, 1)
#define impl_rrep2(i, n) impl_rrep3(i, 0, n)
#define rrep(...) impl_overload4(__VA_ARGS__, impl_rrep4, impl_rrep3, impl_rrep2)(__VA_ARGS__)
// clang-format on

template <typename T>
int bit(T x, unsigned int k) {
  return (x >> k) & 1;
}

template <typename T>
bool chmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  return b < a ? a = b, true : false;
}

inline void yesno(bool b) { output(b ? "Yes" : "No"); }
inline void yes() { yesno(true); }
inline void no() { yesno(false); }
inline void alicebob(bool b) { output(b ? "Alice" : "Bob"); }
inline void alice() { alicebob(true); }
inline void bob() { alicebob(false); }

inline const auto io_setup = [] {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout << std::fixed << std::setprecision(12);
  return 0;
}();

using uint = unsigned int;
using lint = long long;
using ulint = unsigned long long;

using namespace std;

// #define MULTI_TESTCASE

#include <format>

void testcase();

int main() {
#ifndef MULTI_TESTCASE
  testcase();
#else
  auto t = input<int>();
  rep (i, t) {
#ifdef LOCAL
    std::cerr << std::format("\033[36mCase #{}\033[0m\n", i + 1);
#endif
    testcase();
  }
#endif
  return 0;
}

void testcase() {
  auto n = input<int>();
  auto a = input<vector<int>>(n);

  rrep (i, n - 1) a[i + 1] -= a[i];
  int x = 0;
  for (int i = n - 1; i >= 0; i -= 2) x ^= a[i];
  output(x != 0 ? "First" : "Second");
}
0