QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#694905#5420. InscryptionTheLastHutuWA 0ms3812kbC++231.1kb2024-10-31 18:55:022024-10-31 18:55:06

Judging History

你现在查看的是最新测评结果

  • [2024-10-31 18:55:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3812kb
  • [2024-10-31 18:55:02]
  • 提交

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;
}

詳細信息

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'