結果

問題 No.52 よくある文字列の問題
ユーザー kpinkcat
提出日時 2023-10-10 11:07:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 822 bytes
コンパイル時間 1,252 ms
コンパイル使用メモリ 110,280 KB
最終ジャッジ日時 2025-02-17 06:36:04
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 5 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;

int main(){
    string s;
    int ans = 0;
    cin >> s;
    deque<string> dq;
    dq.push_back(s);
    while (!dq.empty()){
        string tmp1, tmp2, tmp3;
        tmp3 = dq.front();
        dq.pop_front();
        tmp1 = tmp2 = tmp3; 
        tmp2.pop_back();
        tmp1 = tmp1.substr(1);
        if (tmp1 == tmp2){
            if (tmp1.size() == 1) ans++;
            else dq.push_back(tmp1);
        } else {
            if (tmp1.size() == 1) ans += 2;
            else {
                dq.push_back(tmp1);
                dq.push_back(tmp2);
            }
        }
    }
    cout << ans << endl;
}
0