結果
問題 |
No.1292 パタパタ三角形
|
ユーザー |
![]() |
提出日時 | 2020-11-20 23:48:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,798 bytes |
コンパイル時間 | 1,730 ms |
コンパイル使用メモリ | 174,892 KB |
実行使用メモリ | 16,256 KB |
最終ジャッジ日時 | 2024-07-23 14:01:15 |
合計ジャッジ時間 | 2,778 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 7 |
ソースコード
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> VI; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; typedef tuple<ll, ll, ll, ll, ll> t5; #define rep(a,n) for(ll a = 0;a < n;a++) #define repi(a,b,n) for(ll a = b;a < n;a++) template<typename T> static inline void chmin(T& ref, const T value) { if (ref > value) ref = value; } template<typename T> static inline void chmax(T& ref, const T value) { if (ref < value) ref = value; } constexpr ll INF = 1e15; int main() { string s; cin >> s; set<P> p; p.emplace(0, 0); int n = s.size(); P current = { 0,0 }; for (int i = 0; i < n; i++) { char c = s[i]; int x = current.first; int y = current.second; if (c == 'a') { if (y % 2 == 0) { if (x % 2 == 0) { current = { x, y + 1 }; } else { current = { x, y - 1 }; } } else { if (x % 2 == 0) { current = { x, y - 1 }; } else { current = { x, y + 1 }; } } } else if (c == 'b') { if (x % 2 == 0) { current = { x+1, y}; } else { current = { x-1, y}; } } else { if (x % 2 == 0) { current = { x - 1, y }; } else { current = { x + 1, y }; } } p.emplace(current); } cout << p.size() << endl; return 0; }