QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722092#5420. InscryptionfieldchaserWA 1ms3592kbC++20909b2024-11-07 17:47:542024-11-07 17:47:54

Judging History

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

  • [2024-11-07 17:47:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3592kb
  • [2024-11-07 17:47:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
#define pb push_back

void solve(){
    int n; cin>>n;
    vector<int> a(n);
    int left=0,num=1,strength=1;
    bool flag=true;
    for (int i=0;i<n;i++){
        cin>>a[i];
        if (a[i]==1) num++,strength++;
        else if (a[i]==-1){
            if (num>1) num--;
            else if (left>=1){
                left--,num+=2,strength++;
            }
            else flag=false;
        }
        else{
            if (num>1) num--,left++;
            else num++,strength++;
        }
    }
    if (!flag) cout<<-1<<"\n";
    else{
        int minn=__gcd(num,strength);
        num/=minn,strength/=minn;
        cout<<strength<<" "<<num<<"\n";
    }
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int t; cin>>t;
    while (t--) solve();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3592kb

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 2
-1
1 1
2 1
-1

result:

wrong answer 2nd lines differ - expected: '3 1', found: '3 2'