QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#727303#881. Gig Combinatoricsgambit#WA 0ms3556kbC++171.3kb2024-11-09 12:37:062024-11-09 12:37:07

Judging History

This is the latest submission verdict.

  • [2024-11-09 12:37:07]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3556kb
  • [2024-11-09 12:37:06]
  • Submitted

answer

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;

    int arr[n];
    int total3=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]==3) total3++;
    }

    vector<pair<ll, ll>> lastTwo;
    ll preSum[n][2]; // [i][1, 2]
    preSum[0][0]=preSum[0][1]=0;
    if(arr[0]==1) preSum[0][0]++;
    else if(arr[0]==2) preSum[0][1]++;
    else lastTwo.push_back({0, total3});

    for(int i=1;i<n;i++){
        preSum[i][0] = preSum[i-1][0];
        preSum[i][1] = preSum[i-1][1];
        if(arr[i]==1) preSum[i][0]++;
        else if(arr[i]==3) preSum[i][1]++;
        else lastTwo.push_back({preSum[i][0], total3-preSum[i][1]});
    }

    ll cnt=0, preSumfor1=0;
    for(int i=0;i<lastTwo.size();i++){
        cnt += lastTwo[i].first*lastTwo[i].second;
        if(i>=1) {
            ll last1 = preSumfor1;
            if(i>=2) {
                last1 = preSumfor1 - lastTwo[i-2].first;
                cnt += lastTwo[i-2].first*lastTwo[i].second*2; // length>2
            }
            cnt += last1*lastTwo[i].second; // length==2
        }
        preSumfor1 += lastTwo[i].first;
        cnt %= 1'000'000'007;
    }
    cout << cnt;



    return 0;
}

詳細信息

Test #1:

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

input:

9
1 1 1 2 2 2 3 3 3

output:

63

result:

ok answer is '63'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

8
1 2 1 2 3 1 2 3

output:

15

result:

ok answer is '15'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3556kb

input:

310
1 2 3 2 2 3 2 3 2 1 2 3 2 3 2 1 2 1 1 2 1 2 3 3 2 2 3 3 2 2 1 1 2 3 2 2 3 2 3 2 1 2 3 2 3 2 1 2 1 1 2 1 2 3 3 2 2 3 3 2 2 2 1 2 3 2 2 3 2 3 2 1 2 3 2 3 2 1 2 1 1 2 1 2 3 3 2 2 3 3 2 2 2 1 2 3 2 2 3 2 3 2 1 2 3 2 3 2 1 2 1 1 2 1 2 3 3 2 2 3 3 2 2 1 1 2 3 2 2 3 2 3 2 1 2 3 2 3 2 1 2 1 1 2 1 2 3 3 ...

output:

6079950

result:

wrong answer expected '265702265', found '6079950'