QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#628981 | #5420. Inscryption | lhfgghc | WA | 144ms | 3948kb | C++14 | 882b | 2024-10-10 23:45:03 | 2024-10-10 23:45:04 |
Judging History
answer
/*
1 1 1 3
1 1 1
1 1
2
1: fz+1&fm+1
-1: fm-1
1 1
2 2
2 1 -
3 3
*/
#include <bits/stdc++.h>
const int N = 1e6 + 10;
int n, a[N];
void solve() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", a + i);
}
if (a[1] == 0) a[1] = 1;
int d = 0;
int fz = 1, fm = 1;
for (int i = 1; i <= n; i++) {
if (a[i] == 1) {
fz++;
fm++;
} else if(a[i] == -1) {
if (fm == 1) {
if (d == 0) {
printf("-1\n");
return;
}
d--;
fm++;
fz++;
fm++;
}
fm--;
} else {
if (fm == 1) {
if (d == 0) {
printf("-1\n");
return;
}
d--;
fm++;
fz++;
fm++;
}
fm--;
d++;
}
}
int g = std::__gcd(fz, fm);
fz /= g;
fm /= g;
printf("%d %d\n", fz, fm);
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3764kb
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: 144ms
memory: 3948kb
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 0 1 0 1 -1 1 0 1 -1 1 0 1 0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