QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#134687 | #5420. Inscryption | heaksicn | TL | 2ms | 5460kb | C++17 | 1.0kb | 2023-08-04 15:15:50 | 2023-08-04 15:15:52 |
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(){
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: 100
Accepted
time: 2ms
memory: 5460kb
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:
3 2 3 1 -1 1 1 2 1 -1
result:
ok 6 lines
Test #2:
score: -100
Time Limit Exceeded
input:
1000000 1 1 1 -1 1 1 1 1 1 1 1 1 1 -1 1 -1 1 0 1 0 1 1 1 0 1 -1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 -1 1 1 1 1 1 -1 1 0 1 1 1 0 1 -1 1 0 1 -1 1 1 1 -1 1 0 1 1 1 1 1 -1 1 0 1 -1 1 -1 1 -1 1 -1 1 0 1 0 1 -1 1 0 1 -1 1 0 1 0 1 0 1 0 1 0 1 -1 1 1 1 0 1 0 1 1 1 0 1 -1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 ...
output:
1 1 -1 1 1 1 1 1 1 1 1 -1 -1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 -1 1 1 1 1 1 1 -1 1 1 -1 1 1 -1 1 1 1 1 1 1 -1 1 1 -1 -1 -1 -1 1 1 1 1 -1 1 1 -1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 1 1 1 1 -1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 ...