QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106461#5420. InscryptionwsygxljWA 217ms3564kbC++141.4kb2023-05-17 20:40:532023-05-17 20:40:54

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-17 20:40:54]
  • 评测
  • 测评结果:WA
  • 用时:217ms
  • 内存:3564kb
  • [2023-05-17 20:40:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int a[1000006];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,c1=0,c2=0,c3=0;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            if(a[i]==1) c1++;
            else if(a[i]==-1) c2++;
            else c3++;
        }
        int r=1,x=1,f=1;
        for(int i=0;i<n;i++)
        {
            if(a[i]==-1)
            {
                if(r<2)
                {
                    f=0;break;
                }
                else r--;
            }
            else r++,x++;
        }
        if(!f) printf("-1\n");
        else
        {
            r=1;x=1;
            r+=c1;x+=c1;
            r-=c2;
         //   cout<<r<<" "<<x<<endl;
            if(r<=0)
            {
                x-=r,c3+=r,r=0;
                r++,x++,c3--;
                int d=c3/2;
                x+=d;
                if(c3%2) x++,r++;
            }
            else
            {
                if(c3>=r-1)
                {
                    c3-=(r-1),r=1;
                    int d=c3/2;
                    x+=d;
                    if(c3%2) x++,r++;
                }
                else r-=c3;
            }
            int g=__gcd(r,x);
        printf("%d %d\n",x/g,r/g);
        }

    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3564kb

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: 217ms
memory: 3504kb

input:

1000000
1
1
1
-1
1
1
1
1
1
1
1
1
1
-1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1
-1
3 2
5 1
1 1
-1
3 2
-1
1 1
-1
2 1
1 1
-1
1 1
-1
1 1
3 2
-1
-1
-1
-1
3 2
5 2
1 1
-1
3 1
-1
-1
1 1
-1
6 1
3 2
-1
3 2
4 3
2 1
-1
5 3
3 1
6 1
-1
2 1
2 1
-1
1 1
-1
3 1
-1
-1
4 1
1 1
2 1
5 2
-1
3 1
3 1...

result:

wrong answer 28th lines differ - expected: '5 4', found: '2 1'