結果

問題 No.1292 パタパタ三角形
ユーザー nawawannawawan
提出日時 2020-11-20 22:24:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 1,989 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 89,212 KB
実行使用メモリ 12,788 KB
最終ジャッジ日時 2023-09-30 19:32:44
合計ジャッジ時間 1,928 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 26 ms
5,292 KB
testcase_08 AC 25 ms
5,104 KB
testcase_09 AC 48 ms
12,292 KB
testcase_10 AC 53 ms
12,464 KB
testcase_11 AC 53 ms
12,236 KB
testcase_12 AC 58 ms
12,788 KB
testcase_13 AC 55 ms
12,724 KB
testcase_14 AC 5 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <complex>
#include <set>
#include <tuple>
#include <utility>
using namespace std;
typedef pair<int, int> P;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    set<P> s;
    s.insert(P(0, 0));
    int flag = 0;
    vector<char> vec(3);
    vec[0] = 3, vec[1] = 2, vec[2] = 1;
    int x = 0, y = 0;
    for(int i = 0; i < S.size(); i++){
        if(flag == 0){
            flag = 1;
            if(vec[S[i] - 'a'] == 3){
                x += 3;
                y += 4;
                for(int j = 0; j < 3; j++){
                    if(vec[j] == 1) vec[j] = 3;
                    else if(vec[j] == 2) vec[j] = 1;
                    else vec[j] = 2;
                }
            }
            else if(vec[S[i] - 'a'] == 2){
                x -= 3;
                y += 4;
                for(int j = 0; j < 3; j++){
                    if(vec[j] == 1) vec[j] = 2;
                    else if(vec[j] == 2) vec[j] = 3;
                    else vec[j] = 1;
                }
            }
            else{
                y -= 5;
            }
        }
        else{
            flag = 0;
            if(vec[S[i] - 'a'] == 3){
                x += 3;
                y -= 4;
                for(int j = 0; j < 3; j++){
                    if(vec[j] == 1) vec[j] = 3;
                    else if(vec[j] == 2) vec[j] = 1;
                    else vec[j] = 2;
                }
            }
            else if(vec[S[i] - 'a'] == 2){
                x -= 3;
                y -= 4;
                for(int j = 0; j < 3; j++){
                    if(vec[j] == 1) vec[j] = 2;
                    else if(vec[j] == 2) vec[j] = 3;
                    else vec[j] = 1;
                }
            }
            else{
                y += 5;
            }
        }
        s.insert(P(x, y));
    }
    cout << s.size() << endl;
}
0