結果

問題 No.1109 調の判定
ユーザー KoDKoD
提出日時 2020-07-10 21:25:30
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,351 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 75,712 KB
最終ジャッジ日時 2024-04-19 15:29:58
合計ジャッジ時間 1,125 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:54:13: error: 'uint32_t' does not name a type
   54 | using i64 = int64_t;
      |             ^~~~~~~~
main.cpp:9:1: note: 'uint32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
    8 | #include <array>
  +++ |+#include <cstdint>
    9 | #include <set>
main.cpp:55:13: error: 'uint64_t' does not name a type
   55 | using u32 = uint32_t;
      |             ^~~~~~~~
main.cpp:55:13: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?

ソースコード

diff #

#line 1 "main.cpp"

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>
#include <set>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { ++i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr range(itr l_, itr r_) noexcept : l(l_), r(std::max(l_, r_)) { }
  constexpr iterator begin() const noexcept { return l; }
  constexpr iterator end() const noexcept { return r; }
};

struct revrange {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { --i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr revrange(itr l_, itr r_) noexcept : l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr iterator begin() const noexcept { return r; }
  constexpr iterator end() const noexcept { return l; }
};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

constexpr i32 D[] = { 0, 2, 4, 5, 7, 9, 11 };

int main() {
  size_t N;
  std::cin >> N;
  std::vector<i32> T(N);
  for (auto &x: T) {
    std::cin >> x;
  }
  std::vector<i32> ans;
  for (auto start: range(0, 12)) {
    std::multiset<i32> st;
    for (auto i: range(0, 7)) {
      st.insert((start + D[i]) % 12);
    }
    bool ok = true;
    for (auto x: T) {
      auto itr = st.find(x);
      if (itr == st.end()) {
        ok = false;
        break;
      }
      st.erase(itr);
    }
    if (ok) {
      ans.push_back(start);
    }
  }
  if (ans.empty() || ans.size() > 1) {
    std::cout << "-1\n";
  }
  else {
    std::cout << ans.front() << '\n';
  }
  return 0;
}
0