結果
| 問題 | 
                            No.3021 Maximize eval
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-02-14 21:41:39 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 8 ms / 2,000 ms | 
| コード長 | 642 bytes | 
| コンパイル時間 | 1,249 ms | 
| コンパイル使用メモリ | 160,596 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2025-02-14 21:41:52 | 
| 合計ジャッジ時間 | 2,325 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 15 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d",&T);
      |         ~~~~~^~~~~~~~~
main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                 scanf("%s",s+1);
      |                 ~~~~~^~~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAX=5e5+10;
char s[MAX];
int main()
{
	int T,n,i,op;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%s",s+1);
		n=strlen(s+1);
		op=1;
		s[n+1]='-';
		for(i=1;i<=n;i++)
		{
			if(s[i]=='-') op=-1;
			else if(s[i]=='+') op=1;
			else if(s[i]=='?')
			{
				if(op==0)
				{
					if(s[i+1]=='+' || s[i+1]=='-') s[i]='1';
					else
					{
						s[i]='+';
						op=1;
					}
				}
				else if(op==-1)
				{
					s[i]='1';
					op=0;
				}
				else s[i]='9';
			}
			else
			{
				if(op==-1) op=0;
			}
		}
		s[n+1]='\0';
		puts(s+1);
	}
	return 0;
}