QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#562006 | #7529. Form Processing | ucup-team052# | WA | 1ms | 3888kb | C++23 | 1.1kb | 2024-09-13 14:09:22 | 2024-09-13 14:09:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 200005
char s[N];
int n;
vector<int> v[N];
vector<int> pos[N];
signed main()
{
#ifdef xay5421
freopen("b.in","r",stdin);
#endif
scanf("%s",s+1);
n=strlen(s+1);
int cur=1,mt=1,lst=1,cnt=0;
for(int i=1;i<=n;i++)
{
if(s[i]=='?')
{
if(cur==1&&mt==1) s[i]='9';
else if(cur==1&&mt==-1) s[i]='1';
else if(cur==-1&&mt==1) s[i]='1';
else pos[lst].push_back(i),cnt++;
}
else if(s[i]=='*') mt=1;
else if(s[i]=='/') mt=-1;
else if(s[i]=='+')
{
if(cur==-1) v[cnt].push_back(lst);
cur=1,cnt=0;
mt=1;
}
else if(s[i]=='-')
{
if(cur==-1) v[cnt].push_back(lst);
cur=-1,cnt=0,lst=i;
mt=1;
}
}
if(cur==-1) v[cnt].push_back(lst);
for(int i=N-1;i>=1;i--)
{
while(v[i].size()>=1)
{
int gov=min((int)v[i].size(),9);
for(int j=0;j<gov;j++)
{
int cid=v[i].back(); v[i].pop_back();
v[i-1].push_back(cid);
int p=pos[cid].back(); pos[cid].pop_back();
s[p]=gov+'0';
}
}
}
printf("%s\n",s+1);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3796kb
input:
?*?+?/?-?
output:
9*9+9/1-1
result:
ok OK!
Test #2:
score: 0
Accepted
time: 1ms
memory: 3884kb
input:
?
output:
9
result:
ok OK!
Test #3:
score: 0
Accepted
time: 1ms
memory: 3888kb
input:
?-?/?-?/?
output:
9-1/2-1/2
result:
ok OK!
Test #4:
score: 0
Accepted
time: 1ms
memory: 3824kb
input:
?-?/?/?/?-?/?+?/?*?
output:
9-1/2/1/1-1/2+9/1*9
result:
ok OK!
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 3820kb
input:
?*?-?+?/?+?*?+?+?-?*?+?-?/?+?/?/?-?/?+?+?*?-?*?*?-?/?/?/?/?/?*?+?+?*?-?*?/?*?/?+?-?-?/?/?*?+?/?-?+?*?*?*?-?*?/?*?-?
output:
9*9-1+9/1+9*9+9+9-1*1+9-1/6+9/1/1-1/6+9+9*9-1*1*1-1/6/3/1/1/1*1+9+9*9-1*1/6*1/3+9-1-1/6/3*1+9/1-1+9*9*9*9-1*1/6*1-1
result:
wrong answer Contestant's answer is not integer