QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#693696#5420. InscryptionReina#WA 0ms3600kbC++231.2kb2024-10-31 16:35:222024-10-31 16:35:24

Judging History

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

  • [2024-10-31 16:35:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-10-31 16:35:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> A(n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &A[i]);
    int sz = 1, can = 0;
    int total = 1;
    for (int i = 0; i < n; ++i)
    {
        if (A[i] == -1)
        {
            if (sz <= 1)
            {
                if (can == 0)
                {
                    cout << -1 << '\n';
                    return ;
                }
                --can;
                --total;
                ++sz;
            }
            else --sz;
        }
        else if (A[i] == 0)
        {
            if (sz <= 1)
                ++sz, ++total;
            else --sz, ++can;
        }
        else ++sz, ++total;
    }
    if (sz < 1)
    {
        cout << -1 << endl;
        return;
    }
    // cout << "?" << endl;
    auto gcd = [&](int x, int y)
    {
        while (y)
        {
            int t = y;
            y = x % y;
            x = t;
        }
        return x;
    };
    cout << total / gcd(total, sz) << " " << sz / gcd(total, sz) << '\n';
}
int main()
{
    int T;
    cin >> T;
    while (T--)
        solve();
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3600kb

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
1 1
-1
1 1
2 1
-1

result:

wrong answer 2nd lines differ - expected: '3 1', found: '1 1'