結果

問題 No.1292 パタパタ三角形
ユーザー KoDKoD
提出日時 2020-11-20 21:38:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,947 bytes
コンパイル時間 611 ms
コンパイル使用メモリ 75,764 KB
最終ジャッジ日時 2024-11-14 23:54:47
合計ジャッジ時間 1,347 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_tree.h:69,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/set:60,
                 from main.cpp:13:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ext/aligned_buffer.h: In instantiation of 'struct __gnu_cxx::__aligned_membuf<std::tuple<long int, long int, bool> >':
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_tree.h:231:41:   required from 'struct std::_Rb_tree_node<std::tuple<long int, long int, bool> >'
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_tree.h:1937:21:   required from 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_erase(_Link_type) [with _Key = std::tuple<long int, long int, bool>; _Val = std::tuple<long int, long int, bool>; _KeyOfValue = std::_Identity<std::tuple<long int, long int, bool> >; _Compare = std::less<std::tuple<long int, long int, bool> >; _Alloc = std::allocator<std::tuple<long int, long int, bool> >; _Link_type = std::_Rb_tree_node<std::tuple<long int, long int, bool> >*]'
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_tree.h:986:9:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::~_Rb_tree() [with _Key = std::tuple<long int, long int, bool>; _Val = std::tuple<long int, long int, bool>; _KeyOfValue = std::_Identity<std::tuple<long int, long int, bool> >; _Compare = std::less<std::tuple<long int, long int, bool> >; _Alloc = std::allocator<std::tuple<long int, long int, bool> >]'
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_set.h:167:7:   required from here
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ext/aligned_buffer.h:56:65: error: invalid application of 'sizeof' to incomplete type 'std::tuple<long int, long int, bool>'
   56 |       alignas(__alignof__(_Tp2::_M_t)) unsigned char _M_storage[sizeof(_Tp)];
      |           

ソースコード

diff #

#line 1 "main.cpp"

/**
 * @title Template
 */

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

#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/chmin_chmax.cpp"

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

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

/**
 * @title Chmin/Chmax
 */
#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

#line 4 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

class range {
  struct iter {
    std::size_t itr;
    constexpr iter(std::size_t pos) noexcept: itr(pos) { }
    constexpr void operator ++ () noexcept { ++itr; }
    constexpr bool operator != (iter other) const noexcept { return itr != other.itr; }
    constexpr std::size_t operator * () const noexcept { return itr; }
  };

  struct reviter {
    std::size_t itr;
    constexpr reviter(std::size_t pos) noexcept: itr(pos) { }
    constexpr void operator ++ () noexcept { --itr; }
    constexpr bool operator != (reviter other) const noexcept { return itr != other.itr; }
    constexpr std::size_t operator * () const noexcept { return itr; }
  };

  const iter first, last;

public:
  constexpr range(std::size_t first, std::size_t last) noexcept: first(first), last(std::max(first, last)) { }
  constexpr iter begin() const noexcept { return first; }
  constexpr iter end() const noexcept { return last; }
  constexpr reviter rbegin() const noexcept { return reviter(*last - 1); } 
  constexpr reviter rend() const noexcept { return reviter(*first - 1); } 
};

/**
 * @title Range
 */
#line 17 "main.cpp"

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

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

int main() {
  std::string S;
  std::cin >> S;
  std::set<std::tuple<isize, isize, bool>> set;
  isize x = 0;
  isize y = 0;
  bool b = false;
  std::string s = "abc";
  set.emplace(x, y, b);
  for (const auto c: S) {
    if (s[0] == c) {
      if (b) {
        y += 1;
      }
      else {
        y -= 1;
      }
    }
    else if (s[1] == c) {
      if (b) {
        s = std::string("") + s[2] + s[0] + s[1];
      }
      else {
        x -= 1;
        s = std::string("") + s[2] + s[0] + s[1];
      }
    }
    else {
      if (b) {
        x += 1;
        s = std::string("") + s[1] + s[2] + s[0];
      }
      else {
        s = std::string("") + s[1] + s[2] + s[0];
      }
    }
    b = !b;
    set.emplace(x, y, b);
    // std::cerr << x << ' ' << y << ' ' << b << ' ' << s << '\n';
  }
  std::cout << set.size() << '\n';
  return 0;
}
0