結果
| 問題 |
No.3021 Maximize eval
|
| コンテスト | |
| ユーザー |
kazuppa
|
| 提出日時 | 2025-02-14 21:45:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 11,019 bytes |
| コンパイル時間 | 4,168 ms |
| コンパイル使用メモリ | 238,136 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-02-14 21:45:37 |
| 合計ジャッジ時間 | 5,266 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 WA * 13 |
ソースコード
#include <bits/stdc++.h>
#include <chrono>
#include <complex>
#include <cmath>
//#define PI M_PI
#include <unistd.h>
#define pc_u putchar
using namespace std;
using ll=long long;
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,a,b) for(it i=(it)(a);i<=(it)b;i++)
#define irep(i,a,b) for(int i=(int)(a);i<=(int)b;i++)
#define irep2(i,a,b,c) for(int i=(int)(a);i<=(int)b;i+=c)
#define nrep(i,a,b) for(it i=(it)(a);i>=(it)b;i--)
#define inrep(i,a,b) for(int i=(int)(a);i>=(int)b;i--)
#define inrep2(i,a,b,c) for(int i=(int)(a);i>=(int)b;i-=c)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define moda 998244353LL
#define modb 1000000007LL
#define modc 968244353LL
#define dai 2500000000000000000LL
#define sho -dai
#define aoi 1e+18
#define tyu 2500000000
#define giri 1000000000
#define en 3.14159265358979
#define eps 1e-14
#define yn(x) out(x?"Yes":"No")
#define YN(x) out(x?"YES":"NO")
#define fi(x) cout<<fixed<<setprecision(x);
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using pairs = pair<T,T>;
using it=long long;
using itn=int;
using un=unsigned long long;
using idb=double;
using db=long double;
using st=string;
using ch=char;
using bo=bool;
using P=pair<it,it>;
using ip=pair<int,int>;
using vi=vector<it>;
using ivi=vector<int>;
using ivd=vector<idb>;
using vd=vector<db>;
using vs=vector<st>;
using vc=vector<ch>;
using vb=vector<bo>;
using vp=vector<P>;
using ivp=vector<ip>;
using sp=set<P>;
using isp=set<ip>;
using ss=set<st>;
using sca=set<ch>;
using si=set<it>;
using isi=set<int>;
using svi=set<vi>;
using vvi=vector<vi>;
using ivvi=vector<ivi>;
using ivvd=vector<ivd>;
using vvd=vector<vd>;
using vvs=vector<vs>;
using vvb=vector<vb>;
using vvc=vector<vc>;
using vvp=vector<vp>;
using ivvp=vector<ivp>;
using vsi=vector<si>;
using ivsi=vector<isi>;
using vsp=vector<sp>;
using ivsp=vector<isp>;
using vvsi=vector<vsi>;
using ivvsi=vector<ivsi>;
using vvsp=vector<vsp>;
using ivvsp=vector<ivsp>;
using vvvi=vector<vvi>;
using ivvvi=vector<ivvi>;
using ivvvd=vector<ivvd>;
using vvvd=vector<vvd>;
using vvvb=vector<vvb>;
using ivvvp=vector<ivvp>;
using vvvvi=vector<vvvi>;
using ivvvvi=vector<ivvvi>;
using vvvvd=vector<vvvd>;
using ivvvvvi=vector<ivvvvi>;
using ivvvvvvi=vector<ivvvvvi>;
using ivvvvvvvi=vector<ivvvvvvi>;
const int dx[8]={0,1,0,-1,1,1,-1,-1};
const int dy[8]={1,0,-1,0,1,-1,1,-1};
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
st num="0123456789";
st mb="xo";
st MB="XO";
#include <atcoder/all>
using namespace atcoder;
using mints=modint998244353;
using mint=modint;
using minto=modint1000000007;
using vm=vector<mint>;
using vms=vector<mints>;
using vmo=vector<minto>;
using vvm=vector<vm>;
using vvms=vector<vms>;
using vvmo=vector<vmo>;
using vvvm=vector<vvm>;
using vvvms=vector<vvms>;
using vvvmo=vector<vvmo>;
using vvvvm=vector<vvvm>;
using vvvvms=vector<vvvms>;
using vvvvmo=vector<vvvmo>;
using vvvvvm=vector<vvvvm>;
using vvvvvms=vector<vvvvms>;
using vvvvvmo=vector<vvvvmo>;
using vvvvvvm=vector<vvvvvm>;
using vvvvvvms=vector<vvvvvms>;
using vvvvvvmo=vector<vvvvvmo>;
/*#define _UNIX03_SOURCE
#include <stdio.h>
int putchar(int c);
struct Scanner {
char *buf;
ssize_t wt, rd;
size_t maxsz;
public:
Scanner(int size = 1<<12): maxsz(size) {
buf = (char*)malloc(sizeof(char) * size);
_read();
}
std::string read_str() {
int ch = _chr();
while (isspace(ch)) ch = nxchar();
int rd_first = rd;
std::string res;
while (rd <= wt && !isspace(buf[rd])) {
++rd;
if (rd == wt) {
res += std::string(buf, rd_first, wt - rd_first);
_read();
rd_first = 0;
}
}
res += std::string(buf, rd_first, rd - rd_first);
return res;
}
char read_chr() {
int ch = _chr();
while (isspace(ch)) ch = nxchar();
return ch;
}
template<class T> T read_int() {
T ret = 0;
bool s = true;
int ch = _chr();
while (isspace(ch)) ch = nxchar();
if (ch == '-') {
s = false;
ch = nxchar();
}
for (; isdigit(ch); ch = nxchar()) ret = ret * 10 + ch - '0';
return (s ? ret : -ret);
}
template<class T> T read_flt() {
return stold(read_str());
}
std::string read_line() {
int ch = _chr();
while (isspace(ch)) ch = nxchar();
int rd_first = rd;
std::string res;
while (rd <= wt && buf[rd] != '\n') {
++rd;
if (rd == wt) {
res += std::string(buf, rd_first, wt - rd_first);
_read();
rd_first = 0;
}
}
res += std::string(buf, rd_first, rd - rd_first);
return res;
}
private:
void _read() {
ssize_t r = read(0, buf, maxsz);
if (r < 0) {
throw std::runtime_error(strerror(errno));
}
wt = r;
rd = 0;
}
inline int nxchar() {
++rd;
if (rd == wt) _read();
return _chr();
}
inline int _chr() {
return rd == wt ? EOF : buf[rd];
}
} sc;
inline short Short() { return sc.read_int<short>(); }
inline unsigned short UShort() { return sc.read_int<unsigned short>(); }
inline int Int() { return sc.read_int<int>(); }
inline unsigned int UInt() { return sc.read_int<unsigned int>(); }
inline long Long() { return sc.read_int<long>(); }
inline unsigned long ULong() { return sc.read_int<unsigned long>(); }
inline long long LLong() { return sc.read_int<long long>(); }
inline unsigned long long ULLong() { return sc.read_int<unsigned long long>(); }
inline __int128_t Int7() { return sc.read_int<__int128_t>(); }
inline __uint128_t UInt7() { return sc.read_int<__uint128_t>(); }
inline float Float() { return sc.read_flt<float>(); }
inline double Double() { return sc.read_flt<double>(); }
inline long double LDouble() { return sc.read_flt<long double>(); }
inline std::string String() { return sc.read_str(); }
inline char Char() { return sc.read_chr(); }
inline bool Bool() { return sc.read_chr() == '1'; }
inline void _SingleInput(short &n) { n = Short(); }
inline void _SingleInput(unsigned short &n) { n = UShort(); }
inline void _SingleInput(int &n) { n = Int(); }
inline void _SingleInput(unsigned int &n) { n = UInt(); }
inline void _SingleInput(long &n) { n = Long(); }
inline void _SingleInput(unsigned long &n) { n = ULong(); }
inline void _SingleInput(long long &n) { n = LLong(); }
inline void _SingleInput(unsigned long long &n) { n = ULLong(); }
inline void _SingleInput(__int128_t &n) { n = Int7(); }
inline void _SingleInput(__uint128_t &n) { n = UInt7(); }
inline void _SingleInput(float &d) { d = Float(); }
inline void _SingleInput(double &d) { d = Double(); }
inline void _SingleInput(long double &d) { d = LDouble(); }
inline void _SingleInput(std::string &s) { s = String(); }
inline void _SingleInput(char &c) { c = Char(); }
inline void _SingleInput(bool &b) { b = Bool(); }
template<class S, class T> inline void _SingleInput(std::pair<S, T> &p) { _SingleInput(p.first); _SingleInput(p.second); }
template<class T> inline void _SingleInput(std::vector<T> &v) { for (T &x: v) _SingleInput(x); }
void input() { }
template<class T1, class... T2> void input(T1& t1, T2&... t2) { _SingleInput(t1); input(t2...); }
template<typename T> inline void print_int(T n) {
if (n < 0) {
pc_u('-');
n = -n;
}
if (n < 10) {
pc_u('0' + n);
return;
}
int i;
char b[21];
b[20] = 0;
for (i = 20; n > 0; b[--i] = '0' + n % 10, n /= 10); fputs(b + i, stdout);
}
template<typename T> void print_bigint(T n) {
if (n < 0) {
pc_u('-');
n = -n;
}
if (n < 10) {
pc_u('0' + n);
return;
}
int i;
char b[41];
b[40] = 0;
for (i = 40; n > 0; b[--i] = '0' + n % 10, n /= 10); fputs(b + i, stdout);
}
void print_char(char c) {
pc_u(c);
}
void print_string(std::string s) {
for (char &c: s) {
pc_u(c);
}
}
template<typename T> void print_double(T d) {
print_string(std::to_string(d));
}
inline void _SingleOutput(short n) { print_int<short>(n); }
inline void _SingleOutput(unsigned short n) { print_int<unsigned short>(n); }
inline void _SingleOutput(int n) { print_int<int>(n); }
inline void _SingleOutput(unsigned int n) { print_int<unsigned int>(n); }
inline void _SingleOutput(long n) { print_int<long>(n); }
inline void _SingleOutput(unsigned long n) { print_int<unsigned long>(n); }
inline void _SingleOutput(long long n) { print_int<long long>(n); }
inline void _SingleOutput(unsigned long long n) { print_int<unsigned long long>(n); }
inline void _SingleOutput(__int128_t n) { print_bigint<__int128_t>(n); }
inline void _SingleOutput(__uint128_t n) { print_bigint<__uint128_t>(n); }
inline void _SingleOutput(float d) { print_double<float>(d); }
inline void _SingleOutput(double d) { print_double<double>(d); }
inline void _SingleOutput(long double d) { print_double<long double>(d); }
inline void _SingleOutput(std::string s) { print_string(s); }
inline void _SingleOutput(char c) { pc_u(c); }
inline void _SingleOutput(bool b) { pc_u(b ? '1' : '0'); }
template<class S, class T> inline void _SingleOutput(std::pair<S, T> p) { _SingleOutput(p.first); pc_u(' '); _SingleOutput(p.second); }
template<class T> inline void _SingleOutput(std::vector<T> v) { for (int i = 0; i < v.size() - 1; i++) { _SingleOutput(v[i]); pc_u(' '); } _SingleOutput(v.back()); }
void print() { pc_u('\n'); }
template<class T1, class... T2> void print(T1 t1, T2... t2) { _SingleOutput(t1); print(t2...); }*/
template<typename T>
void dec(vector<T> &a){
rep(i,0,a.size()-1)a[i]--;
return;
}
template<typename T>
T gcda(T a,T b){
if(!a||!b)return max(a,b);
while(a%b&&b%a){
if(a>b)a%=b;
else b%=a;
}
return min(a,b);
}
it lcma(it a,it b){
return a/gcda(a,b)*b;
}
bo outc(int h,int w,int x,int y){
return (x<0||x>=h||y<0||y>=w);
}
/*総和をもとめるセグ木
struct nod{
it val;
int siz;
nod(it v=0,int s=0):val(v),siz(s){}
};
nod op(nod a,nod b){return nod(a.val+b.val,a.siz+b.siz);}
nod e(){return nod(0,0);}
struct act{
it a;
act(it e=0):a(e){}
};
nod mapping(act f,nod x){return nod(f.a+x.val,x.siz);}
act comp(act f,act g){return act(f.a+g.a);}
act id(){return act(0);}*/
//#define endl '\n'
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;cin>>t;
while(t--){
st s;cin>>s;int n=s.size();
int u=-1;
irep(i,0,n-1){
if(s[i]=='-'||s[i]=='+')break;
else if(s[i]=='?')s[i]='9';
}
irep(i,0,n-1){
if(s[i]=='+'){
u=i+1;
while(u<n&&s[u]!='+'&&s[u]!='-'){
if(s[u]=='?')s[u]='9';
u++;
}
}
else if(s[i]=='-'){
u=i+1;
if(u==n-1||s[u+1]=='-'||s[u+1]=='+'){
if(s[u]=='?')s[u]='1';
}
else if(u==n-2||s[u+2]=='-'||s[u+2]=='+'){
if(s[u]=='?')s[u]='1';
if(s[u+1]=='?')s[u+1]='1';
u++;
}
else{
if(s[u]=='?')s[u]='1';
if(s[u+1]=='?')s[u+1]='+';
u+=2;
while(u<n&&s[u]!='+'&&s[u]!='-'){
if(s[u]=='?')s[u]='9';
u++;
}
}
}
}
cout<<s<<endl;
}
}
kazuppa