結果
問題 | No.1292 パタパタ三角形 |
ユーザー |
![]() |
提出日時 | 2020-05-22 19:35:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 2,171 bytes |
コンパイル時間 | 1,429 ms |
コンパイル使用メモリ | 173,384 KB |
実行使用メモリ | 12,928 KB |
最終ジャッジ日時 | 2024-07-04 18:31:04 |
合計ジャッジ時間 | 2,363 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ string S; cin >> S; set<pair<int, int>> pos; int x = 0; int y = 0; pos.insert(make_pair(x, y)); int N = S.size(); for (int i = 0; i < N; i++){ int X = x % 6; if (X < 0){ X += 6; } int Y = y % 2; if (Y < 0){ Y += 2; } if (S[i] == 'a'){ if (Y == 0){ if (X == 0){ x++; } else if (X == 1){ x--; } else if (X == 2){ y--; } else if (X == 3){ x++; } else if (X == 4){ x--; } else if (X == 5){ y++; } } else { if (X == 0){ x++; } else if (X == 1){ x--; } else if (X == 2){ y++; } else if (X == 3){ x++; } else if (X == 4){ x--; } else if (X == 5){ y--; } } } if (S[i] == 'b'){ if (Y == 0){ if (X == 0){ y--; } else if (X == 1){ x++; } else if (X == 2){ x--; } else if (X == 3){ y++; } else if (X == 4){ x++; } else if (X == 5){ x--; } } else { if (X == 0){ y++; } else if (X == 1){ x++; } else if (X == 2){ x--; } else if (X == 3){ y--; } else if (X == 4){ x++; } else if (X == 5){ x--; } } } if (S[i] == 'c'){ if (Y == 0){ if (X == 0){ x--; } else if (X == 1){ y++; } else if (X == 2){ x++; } else if (X == 3){ x--; } else if (X == 4){ y--; } else if (X == 5){ x++; } } else { if (X == 0){ x--; } else if (X == 1){ y--; } else if (X == 2){ x++; } else if (X == 3){ x--; } else if (X == 4){ y++; } else if (X == 5){ x++; } } } pos.insert(make_pair(x, y)); } cout << pos.size() << endl; }