QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#639979#5420. InscryptionciyekuaWA 130ms3708kbC++231.5kb2024-10-14 01:00:152024-10-14 01:00:15

Judging History

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

  • [2024-10-14 01:00:15]
  • 评测
  • 测评结果:WA
  • 用时:130ms
  • 内存:3708kb
  • [2024-10-14 01:00:15]
  • 提交

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) {
            	if(sum<=1) fl=1;
                sum--;
            }
            if(x==0) {
                zero++;
            }
            if(sum==0) {
                if(zero>0) {
                    sum++;
                    lisum++;
                    zero--;
                }
                else {
                	fl=1;
                }
            }
            if(sum==1) {
            	if(zero>0) {
                    sum++;
                    lisum++;
                    zero--;
                }
            }

        }
        //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;
}

詳細信息

Test #1:

score: 100
Accepted
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:

3 2
3 1
-1
1 1
2 1
-1

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 130ms
memory: 3708kb

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

result:

wrong answer 91st lines differ - expected: '5 3', found: '4 1'