QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#639967 | #5420. Inscryption | ciyekua | WA | 135ms | 3712kb | C++23 | 1.4kb | 2024-10-14 00:44:53 | 2024-10-14 00:44:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0),cin.tie(0);
int t,n,x,lisum,sum,zero;
cin>>t;
while(t--) {
int fl=0;
lisum=1,sum=1,zero=0;
cin>>n;
for(int i=0;i<n;i++) {
cin>>x;
if(x==1) {
lisum++;
sum++;
}
if(x==-1) {
sum--;
}
if(x==0) {
zero++;
}
if(sum==1||sum==0) {
if(zero>0) {
sum++;
lisum++;
zero--;
}
else {
fl=1;
}
}
}
//cout<<sum<<" "<<zero<<" "<<sum<<"#\n";
if(fl==0)
while(1) {
if(zero==0) break;
if(sum==1) {
sum++;
lisum++;
}
else sum--;
zero--;
}
if(fl==1) cout<<"-1\n";
else {
int gcd0=__gcd(lisum,sum);
while(1) {
if(gcd0==1) break;
lisum/=gcd0;
sum/=gcd0;
gcd0=__gcd(lisum,sum);
}
cout<<lisum<<" "<<sum<<"\n";
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
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: 0
Accepted
time: 135ms
memory: 3712kb
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 -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