結果

問題 No.1292 パタパタ三角形
ユーザー okok
提出日時 2020-11-20 22:23:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,758 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 88,544 KB
実行使用メモリ 16,028 KB
最終ジャッジ日時 2023-09-30 19:31:52
合計ジャッジ時間 1,840 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 30 ms
6,088 KB
testcase_08 AC 29 ms
5,960 KB
testcase_09 AC 53 ms
15,344 KB
testcase_10 AC 57 ms
15,264 KB
testcase_11 AC 55 ms
15,288 KB
testcase_12 AC 66 ms
15,888 KB
testcase_13 AC 68 ms
16,028 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<set>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int x = 0, y = 0, z = 0;
    set<pair<pair<int,int>,int>> S;
    string s;
    
    cin>>s;
    
    S.insert({{x,y},z});
    
    for(int i = 0; i < s.size(); i++){
        int temp = ((y - x) % 3 + 3) % 3;
        if(temp == 0) {
            if(!z) {
                if(s[i] == 'a') x--;
                // if(s[i] == 'b') z++;
                if(s[i] == 'c') y--;
            } else {
                if(s[i] == 'a') y++;
                // if(s[i] == 'b') z--;
                if(s[i] == 'c') x++;
            }
        } else if(temp == 1) {
            if(!z) {
                if(s[i] == 'b') x--;
                // if(s[i] == 'c') z++;
                if(s[i] == 'a') y--;
            } else {
                if(s[i] == 'b') y++;
                // if(s[i] == 'c') z--;
                if(s[i] == 'a') x++;
            }
        } else if(temp == 2) {
            if(!z) {
                if(s[i] == 'c') x--;
                // if(s[i] == 'a') z++;
                if(s[i] == 'b') y--;
            } else {
                if(s[i] == 'c') y++;
                // if(s[i] == 'a') z--;
                if(s[i] == 'b') x++;
            }
        }
        z = !z;
        S.insert({{x,y},z});
        // cout<<x<<" "<<y<<" "<<z<<" "<<temp<<" "<<S.size()<<endl;
    }
	
    cout<<S.size()<<endl;
	
	return 0;
}
0