QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#733382#5420. InscryptionwantsthWA 0ms3620kbC++23919b2024-11-10 18:32:402024-11-10 18:32:40

Judging History

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

  • [2024-11-10 18:32:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-11-10 18:32:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int n;
	cin>>n;
	vector<int>a(n+1);
	int x=1;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int num=1;
	int k=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==1)
		{
			x+=1;
			num+=1;
		}
	    else if(a[i]==-1)
		{
			num-=1;
		}
		else
		{
			k+=1;
		}
		if(num==0)
		{
			if(k>0)
			{
				k-=1;
				x+=1;
				num+=1;
			}
			else
			{
				cout<<-1<<endl;
				return;
			}
		}
	}
	cout<<x<<" "<<num<<" "<<k<<endl;
	if(k>0)
	{
		if(num>k)
		{
			x+=k;
			num-=k;
		}
		else
		{
			int shu=num;
			num=1;
			k-=(shu-1);
			if(k%2==0)
			{
				x+=k/2;
			}
			else
			{
				x+=k/2+1;
				num+=1;
			}
		}
	}
	int gg=__gcd(x,num);
	cout<<x/gg<<" "<<num/gg<<endl;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		solve();
	 } 
 } 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3620kb

input:

6
7
1 1 1 -1 1 1 -1
4
1 0 -1 0
4
0 -1 -1 0
1
0
2
0 0
1
-1

output:

6 4 0
3 2
2 1 2
3 1
-1
1 1 1
1 1
1 1 2
2 1
-1

result:

wrong answer 1st lines differ - expected: '3 2', found: '6 4 0'