QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#134689 | #5420. Inscryption | heaksicn | WA | 1ms | 5488kb | C++14 | 1.1kb | 2023-08-04 15:19:56 | 2023-08-04 15:19:59 |
Judging History
answer
//Man always remember love because of romance only!
#include<bits/stdc++.h>
using namespace std;
inline int read(){
int X=0,w=0; char ch=0;
while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
return w?-X:X;
}
inline void write(int x){
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
}
int a[1000010];
int q[1000010],cnt;
int gcd(int x,int y){
if(y==0) return x;
return gcd(y,x%y);
}
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);
a[0]=1;
int T=read();
for(int i=1;i<=T;i++){
int n=read();
int x=0,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{
int x=0,y=0;
for(int j=0;j<=n;j++){
if(a[j]==1)x++,y++;
else x--;
if(x<=0)x+=2,y++;
}
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: 1ms
memory: 5488kb
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:
5 2 1 1 1 1 1 1 0 1 1 1
result:
wrong answer 1st lines differ - expected: '3 2', found: '5 2'