QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#105971#5420. Inscryption0xyz#WA 0ms3496kbC++14679b2023-05-16 08:59:432023-05-16 08:59:47

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-16 08:59:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3496kb
  • [2023-05-16 08:59:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t,n,x,y,fl,a[1000010];
inline void out(int x,int y){
	if(!x)cout<<"0 1\n";
	else{
		int g=__gcd(x,y);
		x/=g;y/=g;
		cout<<x<<' '<<y<<'\n';
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>t;a[0]=1;
	for(int i=1;i<=t;i++){
		cin>>n;
		x=fl=0;
		for(int j=1;j<=n;j++)cin>>a[j];
		for(int j=0;j<=n;j++){
			if(a[j]>=0)x++;
			else x--;
			if(x<=0)fl=1;
		}
		if(fl)cout<<"-1\n";
		else{
			x=y=0;
			for(int j=0;j<=n;j++){
				if(a[j]==1)x++,y++;
				else x--;
				if(x<=0)x+=2,y++;
			}
			cout<<y<<'\n';
			out(y,2*y-(n+1));
		}
	}
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
3 2
3
3 1
-1
2
1 1
2
2 1
-1

result:

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