QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105971 | #5420. Inscryption | 0xyz# | WA | 0ms | 3496kb | C++14 | 679b | 2023-05-16 08:59:43 | 2023-05-16 08:59:47 |
Judging History
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'