QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#228552#5420. Inscryptionmobbb#WA 127ms3688kbC++171.2kb2023-10-28 13:41:522023-10-28 13:41:53

Judging History

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

  • [2023-10-28 13:41:53]
  • 评测
  • 测评结果:WA
  • 用时:127ms
  • 内存:3688kb
  • [2023-10-28 13:41:52]
  • 提交

answer

#include"bits/stdc++.h"
using namespace std;
using ll=long long;
const int N=1e5+5;
const ll mod=1e9+7;

void save_the_people(){
    int a,b,n,now=1,atk=1,ston=0,pos=0,choose=0;
    cin>>n;bool ok = true;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a==1){
            atk++;
            now++;
        }
        if(a==-1){
            now--;
        }
        if(a==0)choose++;
        if(now==0&&choose==0){ok=false;}
        if(now==0&&choose>0){now++,choose--;atk++;}
    }
    if(!ok) {
        cout << "-1\n";
        return;
    }
    if(now==1&&choose==1) { atk++,now++, choose--; }
    //cout<<atk<<' '<<choose<<' '<<now <<'\n';
    if(now>choose )now-=choose;
    //cout<<choose<<' '<<now<<' '<<atk<<'\n';
    if(now==choose) {
        now = now + 2 - choose;
        atk+=2;
    }
    if(now<choose){
        choose=choose-now+1;
        now=1;
    }

    atk+=(choose/2);
    if(choose%2){
        now++;
    }
    int t = gcd(atk,now);
    atk /= t;
    now /= t;
    cout<<atk << ' '<<now<<'\n';

}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int _{1};cin>>_;
    while(_--){
        save_the_people();
    }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

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: 127ms
memory: 3688kb

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
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-1
1 1
3 2
-1
-1
-1
-1
3 2
7 1
1 1
-1
5 2
-1
-1
1 1
-1
6 1
1 1
-1
3 2
1 1
2 1
-1
5 3
4 1
6 1
-1
2 1
4 3
-1
1 1
-1
3 1
-1
-1
2 1
1 1
2 1
5 2
-1
5 3
4 3...

result:

wrong answer 4th lines differ - expected: '3 2', found: '5 2'