QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#570836#5414. Stop, Yesterday Please No MoreAbclWA 0ms3924kbC++141.1kb2024-09-17 18:19:112024-09-17 18:19:11

Judging History

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

  • [2024-09-17 18:19:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3924kb
  • [2024-09-17 18:19:11]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
const int N=200005;
int n;
int x[N];
void solve(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x[i]);
	}
	int s0=0;
	int sum=1,a=1;
	
	for(int i=1;i<=n;i++){
		if(x[i]==1){//增加一只
			a++,sum++;
		}
		else if(x[i]==-1){//减少一只
			if(a==1){//剩下的就一只了
			
				if(s0>0){//还有可以转化的 0
					s0--; //把一个作为 -1的 0 转变为1
					a=a+2;
					sum++;
					a--;
				}
				else {
					printf("-1\n");
					return;
				}
				
			}
			else a--;
		}
		else if(x[i]==0){
			if(a==1){//只有一个了 那么我只能选择做 1
				a++,sum++;
			}
			else {
				a--,s0++;
			}
		}
	}
	int cc=__gcd(sum,a);
	sum/=cc,a/=cc;
	printf("%lld %lld\n",sum,a);
	return;
}
signed main() {
//	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int T_case=1;
	cin>>T_case;
	while(T_case--){
		solve();
	}
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
4 5 3
ULDDRR
4 5 0
UUUUUUU
4 5 10
UUUUUUU

output:

2 1
2 1
2 1

result:

wrong answer 2nd numbers differ - expected: '20', found: '1'