結果

問題 No.1292 パタパタ三角形
ユーザー nawawannawawan
提出日時 2020-11-20 22:24:53
言語 C++14
(gcc 12.2.0 + boost 1.81.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 1,989 bytes
コンパイル時間 633 ms
実行使用メモリ 12,836 KB
最終ジャッジ日時 2023-02-23 18:58:22
合計ジャッジ時間 1,918 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,196 KB
testcase_01 AC 1 ms
6,252 KB
testcase_02 AC 1 ms
6,188 KB
testcase_03 AC 1 ms
6,196 KB
testcase_04 AC 2 ms
6,192 KB
testcase_05 AC 1 ms
6,200 KB
testcase_06 AC 1 ms
6,212 KB
testcase_07 AC 22 ms
6,200 KB
testcase_08 AC 21 ms
6,284 KB
testcase_09 AC 42 ms
12,432 KB
testcase_10 AC 42 ms
12,436 KB
testcase_11 AC 42 ms
12,204 KB
testcase_12 AC 49 ms
12,780 KB
testcase_13 AC 48 ms
12,836 KB
testcase_14 AC 4 ms
6,252 KB
testcase_15 AC 3 ms
6,196 KB
testcase_16 AC 3 ms
6,268 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