QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#228674#5420. Inscryptionmobbb#WA 115ms3600kbC++171.2kb2023-10-28 13:56:542023-10-28 13:56:55

Judging History

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

  • [2023-10-28 13:56:55]
  • 评测
  • 测评结果:WA
  • 用时:115ms
  • 内存:3600kb
  • [2023-10-28 13:56:54]
  • 提交

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;
    }//cout<<choose<<' '<<now<<' '<<atk<<'\n';
    if(now==1&&choose==1) { atk++,now++, choose--; }
    //cout<<atk<<' '<<choose<<' '<<now <<'\n';
    else if(now>choose )now-=choose;

    else if(now==choose) {
        now++;atk++;
        choose--;
        now = now - choose;
        choose = 0;
    }
    else if(now<choose){
        choose=choose-now+1;
        now=1;
    }

    atk+=(choose/2);
    if(choose%2){
        now++;atk++;
    }
    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: 3368kb

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: 115ms
memory: 3420kb

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

result:

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