QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#733382 | #5420. Inscryption | wantsth | WA | 0ms | 3620kb | C++23 | 919b | 2024-11-10 18:32:40 | 2024-11-10 18:32:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin>>n;
vector<int>a(n+1);
int x=1;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int num=1;
int k=0;
for(int i=0;i<n;i++)
{
if(a[i]==1)
{
x+=1;
num+=1;
}
else if(a[i]==-1)
{
num-=1;
}
else
{
k+=1;
}
if(num==0)
{
if(k>0)
{
k-=1;
x+=1;
num+=1;
}
else
{
cout<<-1<<endl;
return;
}
}
}
cout<<x<<" "<<num<<" "<<k<<endl;
if(k>0)
{
if(num>k)
{
x+=k;
num-=k;
}
else
{
int shu=num;
num=1;
k-=(shu-1);
if(k%2==0)
{
x+=k/2;
}
else
{
x+=k/2+1;
num+=1;
}
}
}
int gg=__gcd(x,num);
cout<<x/gg<<" "<<num/gg<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3620kb
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 4 0 3 2 2 1 2 3 1 -1 1 1 1 1 1 1 1 2 2 1 -1
result:
wrong answer 1st lines differ - expected: '3 2', found: '6 4 0'