QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#562695#5420. Inscryptiongogo11#WA 145ms3588kbC++201.2kb2024-09-13 20:06:292024-09-13 20:06:29

Judging History

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

  • [2024-09-13 20:06:29]
  • 评测
  • 测评结果:WA
  • 用时:145ms
  • 内存:3588kb
  • [2024-09-13 20:06:29]
  • 提交

answer

 #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int N = 5e5 + 5;
constexpr int M = 2e5 + 5;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LNF = 0x3f3f3f3f3f3f3f3f;
constexpr int Mod = 1000000007;
constexpr ll Base = 131;
constexpr int MaXBIT = 30;
constexpr double eps = 1e-9;
void solve()
{
    int n,cnt1=1,cnt2=0,cnt3=0;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++) {
        if(a[i]==1) {
            cnt1+=1;
        }
        else if(a[i]==-1) {
            cnt2+=1;
            if(cnt2>=cnt1+cnt3) {
                cout<<"-1\n";
                return;
            }
            if(cnt2>=cnt1) {
                cnt1+=1;
                cnt3-=1;
            }
        }
        else {
            cnt3+=1;
        }
    }
    n+=1;
    int x=max(cnt1,n/2+1),y=2*x-n,g=gcd(x,y);
    x/=g,y/=g;
    cout<<x<<" "<<y<<"\n";
}
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(2);
    int _=1;
    cin>>_;
    while(_--)
        solve();
    return 0;
}

詳細信息

Test #1:

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

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: 145ms
memory: 3556kb

input:

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

result:

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