結果

問題 No.3021 Maximize eval
ユーザー GOTKAKO
提出日時 2025-02-14 21:52:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 1,865 ms
コンパイル使用メモリ 193,048 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-14 21:54:52
合計ジャッジ時間 3,079 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T; cin >> T;
    while(T--){
        string s; cin >> s;
        bool plus = true,back = false;
        int pos = 0;
        s += '-';
        for(auto &c : s){
            if(c == '+') plus = true,back = true;
            else if(c == '-') plus = false,back = true;
            else if(c == '?'){
                if(plus) c = '9',back = false;
                else if(back || (s.at(pos+1) == '-' || s.at(pos+1) == '+')) c = '1',back = false;
                else c = '+',plus = true,back = true;
            }
            else back = false;
            pos++;
        }
        s.pop_back();
        cout << s << "\n";
    }
}
0