QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#430026 | #5420. Inscryption | mangooo | WA | 1ms | 3612kb | C++20 | 1.0kb | 2024-06-03 11:37:36 | 2024-06-03 11:37:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
typedef pair<int, int> PII;
void solve()
{
int n;
cin >> n;
int c1 = 0, c2 = 0, c3 = 0;
int is = 0;
for(int i = 0; i < n; i++)
{
int x;
cin >> x;
if(x == 1) c1++;
else if(x == -1) c2++;
else c3++;
if(c2 >= c1 + c3 && c2) is = 1;
}
if(is) cout << "-1\n";
else
{
int x = c1 + 1, y = c1 - c2 + 1;
if(y <= 0)
{
c3 += y - 1;
y = 1;
if(c3 % 2)
{
x++;
y++;
c3--;
}
x += c3 / 2;
if(y != 1 && x % y == 0)
{
y = 1;
x /= y;
}
cout << x << ' ' << y << '\n';
}
else
{
if(c3 % 2)
{
x++;
y++;
c3--;
}
x += c3 / 2;
if(y != 1 && x % y == 0)
{
y = 1;
x /= y;
}
cout << x << ' ' << y << '\n';
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while(t--) solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3612kb
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:
6 4 3 1 -1 2 1 2 1 -1
result:
wrong answer 1st lines differ - expected: '3 2', found: '6 4'