QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#562006#7529. Form Processingucup-team052#WA 1ms3888kbC++231.1kb2024-09-13 14:09:222024-09-13 14:09:23

Judging History

你现在查看的是最新测评结果

  • [2024-09-13 14:09:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3888kb
  • [2024-09-13 14:09:22]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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