QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#624033#5420. InscryptionLcaokai#WA 145ms3848kbC++201.2kb2024-10-09 14:45:492024-10-09 14:45:50

Judging History

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

  • [2024-10-09 14:45:50]
  • 评测
  • 测评结果:WA
  • 用时:145ms
  • 内存:3848kb
  • [2024-10-09 14:45:49]
  • 提交

answer

#include<bits/stdc++.h>

#define endl '\n'
using ll = long long;
using ld = long double;
using namespace std;

void solve() {
    ll n; cin>>n;
    vector <ll> a(n+1);
    ll num=1;
    ll cnt=0;
    ll sum=1;
    for(ll i=1;i<=n;i++) cin>>a[i];
    for(ll i=1;i<=n;i++) {
        if(a[i]==1) {
            sum++;
            num++;
        }
        if(a[i]==0) cnt++;
        if(a[i]==-1) {
            if(num==1) {
                if(cnt) {
                    cnt--;
                    sum++;
                }else {
                    cout<< -1 <<endl; return ;
                }
            }else num--;
        }
    }
    if(num>cnt) num-=cnt;
    else {
        while(num<=cnt) {
            num++;
            sum++;
            cnt--;
        }
        num-=cnt;
    }
    ll g=__gcd(num,sum);
    cout<<sum/g<<' '<<num/g<<endl;
    // ll n,k,m,c,d;
    // cin>>n>>k>>m>>c>>d;
    //
    // vector<ll>a(n+1);
    // for(int i=1;i<=n;i++) {
    //     cin>>a[i];
    //
    //     a[i]+=
    // }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int ttt = 1;
    cin >> ttt;
    while (ttt--) {
        solve();
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3804kb

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: 145ms
memory: 3776kb

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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
-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
4 3...

result:

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