結果
問題 | No.1292 パタパタ三角形 |
ユーザー | ninoinui |
提出日時 | 2020-11-20 21:49:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 1,181 bytes |
コンパイル時間 | 2,178 ms |
コンパイル使用メモリ | 197,772 KB |
最終ジャッジ日時 | 2025-01-16 02:15:41 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> bool cmin(T &a, U b) { return a > b && (a = b, true); } template <typename T, typename U> bool cmax(T &a, U b) { return a < b && (a = b, true); } signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); string S; cin >> S; int N = S.size(); 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 < N; i++) { int now = S.at(i) - 'a'; if (f) { if (now == a) { SE.insert({x, --y}); } else if (now == b) { SE.insert({--x, y}); int tmp = a; a = c; c = b; b = tmp; } else { SE.insert({++x, y}); int tmp = a; a = b; b = c; c = tmp; } f = 0; } else { if (now == a) { SE.insert({x, ++y}); } else if (now == b) { SE.insert({--x, y}); int tmp = a; a = c; c = b; b = tmp; } else { SE.insert({++x, y}); int tmp = a; a = b; b = c; c = tmp; } f = 1; } } cout << SE.size() << "\n"; }