結果

問題 No.1292 パタパタ三角形
ユーザー iomir
提出日時 2023-03-29 10:49:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 1,775 ms
コンパイル使用メモリ 175,452 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2024-09-21 04:28:56
合計ジャッジ時間 2,751 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define all(v) v.begin(),v.end()
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using P = pair<ll,ll>;

int main(){
    string S;
    cin>>S;
    ll N=S.size();
    char l='b',r='c',u='c';
    ll lr=0,ud=0;
    map<P,ll> mp;
    mp[make_pair(0,0)]++;
    for(int i=0;i<N;i++){
        if(S[i]==l){
            lr--;
            swap(l,r);
            mp[make_pair(lr,ud)]++;
        }else if(S[i]==r){
            lr++;
            swap(l,r);
            mp[make_pair(lr,ud)]++;
        }else{
            if((lr+ud)%2==0)ud--;
            else ud++;
            mp[{lr,ud}]++;
        }
    }
    cout << mp.size() << endl;
}
0