結果

問題 No.1292 パタパタ三角形
ユーザー ninoinuininoinui
提出日時 2020-11-21 10:04:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 205,944 KB
実行使用メモリ 12,844 KB
最終ジャッジ日時 2023-09-30 21:39:40
合計ジャッジ時間 3,046 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 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,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 29 ms
5,292 KB
testcase_08 AC 29 ms
5,204 KB
testcase_09 AC 50 ms
12,484 KB
testcase_10 AC 50 ms
12,212 KB
testcase_11 AC 52 ms
12,372 KB
testcase_12 AC 57 ms
12,844 KB
testcase_13 AC 57 ms
12,700 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 7 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  string S;
  cin >> S;
  set<pair<int, int>> SE;
  SE.insert({0, 0});
  for (int i = 0, f = 0, a = 0, b = 1, c = 2, x = 0, y = 0; i < S.size(); i++, f ^= 1) {
    int s = S[i] - 'a';
    if (s == a) (f) ? SE.insert({x, ++y}) : SE.insert({x, --y});
    else if (s == b) SE.insert({--x, y}), swap(a, b), swap(a, c);
    else SE.insert({++x, y}), swap(a, c), swap(a, b);
  }
  cout << SE.size() << "\n";
}
0