QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#694905 | #5420. Inscryption | TheLastHutu | WA | 0ms | 3812kb | C++23 | 1.1kb | 2024-10-31 18:55:02 | 2024-10-31 18:55:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
using pii = pair<int,int>;
const int inf = 1e10;
void solve() {
int n;
cin >> n;
vector<int> v(n + 1, 0);
for (int i = 1; i <= n; ++i) cin >> v[i];
int sum = 1, cnt = 1, zero = 0;
int fh = 0;
for (int i = 1; i <= n; ++i) {
if (v[i] == 1)++sum, ++cnt;
else if (v[i] == 0) {
if (cnt > 1)++fh, --cnt;
else ++sum, ++cnt;
} else {
if (cnt == 1) {
if (fh) {
--fh, ++cnt;//1.反悔
++sum, ++cnt;//反悔变成1
--cnt;//进行-1操作
} else {
cout << -1 << endl;
return;
}
} else --cnt;
}
}
int g = __gcd(sum, cnt);
cout << sum / g << ' ' << sum / cnt << endl;
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _=1;
cin>>_;
while(_--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3812kb
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 1 3 3 -1 1 1 2 2 -1
result:
wrong answer 1st lines differ - expected: '3 2', found: '3 1'