QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#693696 | #5420. Inscryption | Reina# | WA | 0ms | 3600kb | C++23 | 1.2kb | 2024-10-31 16:35:22 | 2024-10-31 16:35:24 |
Judging History
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();
}
Details
Tip: Click on the bar to expand more detailed information
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'