結果
| 問題 | No.1292 パタパタ三角形 | 
| コンテスト | |
| ユーザー |  chocorusk | 
| 提出日時 | 2020-11-20 23:31:11 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 64 ms / 2,000 ms | 
| コード長 | 1,205 bytes | 
| コンパイル時間 | 1,342 ms | 
| コンパイル使用メモリ | 129,952 KB | 
| 最終ジャッジ日時 | 2025-01-16 03:26:10 | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
string t="abc";
int main()
{
    string s; cin>>s;
    int n=s.size();
    set<P> st[2];
    st[0].insert({0, 0});
    int x=0, y=0, p=0;
    for(int i=0; i<n; i++){
        if(p==0){
            int k=t.find(s[i]);
            k=((x-y)%3+3+k)%3;
            if(k==0){
                x++;
            }else if(k==1){
                x++; y--;
            }
        }else{
            int k=t.find(s[i]);
            k=((x-y)%3+3+k)%3;
            if(k==1){
                x--;
            }else if(k==0){
                x--; y++;
            }
        }
      p^=1;
        st[p].insert({x, y});
    }
    cout<<st[0].size()+st[1].size()<<endl;
	return 0;
}
            
            
            
        