QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#613451 | #5420. Inscryption | ucup-team1769# | WA | 118ms | 3644kb | C++20 | 1.7kb | 2024-10-05 14:02:09 | 2024-10-05 14:05:56 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e6;
signed main()
{
IOS;
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
int fz = 1, fm = 1, f = 0;
int ff = 1;
for (int i = 0; i < n; i++)
{
int op;
cin >> op;
if (!ff)
continue;
if (op == 1)
{
fz++;
fm++;
}
else if (op == 0)
{
f++;
}
else if (op == -1)
{
if (fm > 1)
{
fm--;
}
else
{
if (f > 0)
{
f--;
fz++;
}
else
{
ff = 0;
}
}
}
}
if (!ff)
{
cout << "-1\n";
}
else
{
if (f > 0 && fm > 1)
{
int x = min(fm - 1, f);
fm -= x;
f -= f;
}
if (f > 0)
{
int x = (f + 1) / 2;
fz += x;
fm += f % 2;
}
int _ = gcd(fz, fm);
cout << fz / _ << " " << fm / _ << endl;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3644kb
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: 118ms
memory: 3568kb
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 1 1 0 1 0 1 0 1 1 1 -1 1 1 1 1 1 -1 1 0 1 1 1 0 1 -1 1 0 1 -1 1 1 1 -1 1 0 1 1 1 1 1 -1 1 0 1 -1 1 -1 1 -1 1 -1 1 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