結果

問題 No.1292 パタパタ三角形
ユーザー m_tsubasam_tsubasa
提出日時 2020-11-20 21:33:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 2,039 ms
コンパイル使用メモリ 205,664 KB
実行使用メモリ 12,740 KB
最終ジャッジ日時 2023-09-30 18:58:58
合計ジャッジ時間 3,096 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 27 ms
5,324 KB
testcase_08 AC 27 ms
5,212 KB
testcase_09 AC 46 ms
12,500 KB
testcase_10 AC 48 ms
12,248 KB
testcase_11 AC 47 ms
12,220 KB
testcase_12 AC 57 ms
12,664 KB
testcase_13 AC 55 ms
12,740 KB
testcase_14 AC 7 ms
4,380 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 7 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using P = pair<int, int>;
string s;
set<P> st;

int solve();

int main() {
  cin >> s;
  cout << solve() << endl;
  return 0;
}

int solve() {
  int n = s.size(), x = 0, y = 0;
  string t = "abc";
  st.insert(P(0, 0));
  for (int i = 0; i < n; ++i) {
    if (i & 1) {
      if (s[i] == t[0])
        ++y;
      else if (s[i] == t[1])
        ++x, swap(t[0], t[1]), swap(t[0], t[2]);
      else
        --y, swap(t[0], t[1]), swap(t[1], t[2]);
    } else {
      if (s[i] == t[0])
        --y;
      else if (s[i] == t[1])
        ++y, swap(t[1], t[2]), swap(t[0], t[1]);
      else
        --x, swap(t[0], t[2]), swap(t[0], t[1]);
    }
    st.insert(P(x, y));
  }
  return st.size();
}
0