QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#325167#5607. Cribbage On Steroidsaggrovector#WA 1ms3688kbC++141.7kb2024-02-11 05:23:452024-02-11 05:23:47

Judging History

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

  • [2024-02-11 05:23:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3688kb
  • [2024-02-11 05:23:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
long long n,i,cnt[15],a[105],v[105],dp[105][20],score1,score2,score3,num,s,j;
char c;

int main() {
    cin >> n;
    for (i=1;i<=n;i++) {
        cin >> c;
        if (c=='A') {
            a[i]=1;
            v[i]=1;
        }
        else if (c>='2' && c<='9') {
            a[i]=c-'0';
            v[i]=c-'0';
        }
        else if (c=='T') {
            a[i]=10;
            v[i]=10;
        }
        else if (c=='J') {
            a[i]=11;
            v[i]=10;
        }
        else if (c=='Q') {
            a[i]=12;
            v[i]=10;
        }
        else if (c=='K') {
            a[i]=13;
            v[i]=10;
        }
    }
    for (i=1;i<=n;i++) {
        cnt[a[i]]++;
    }
    dp[0][0]=1;
    for (i=1;i<=n;i++) {
        for (j=0;j<=15;j++) {
            dp[i][j]=dp[i-1][j];
            if (j-v[i]>=0) {
                dp[i][j]+=dp[i-1][j-v[i]];
            }
        }
    }
    // for (i=1;i<=n;i++) {
    //     for (j=1;j<=15;j++) {
    //         cout << dp[i][j] << ' ';
    //     }

    //     cout << endl;
    // }
    // cout << endl;
    score1=dp[n][15]*2;
    for (i=1;i<=13;i++) {
        if (cnt[i]>=2) {
            score2+=cnt[i]*(cnt[i]-1)/2;
        }
    }
    score2*=2;
    s=1;
    for (i=1;i<=13;i++) {
        if (cnt[i]==0) {
            if (num>=3) {
                score3+=s*num;
            }
            s=1;
            num=0;
        }
        else {
            s*=cnt[i];
            num++;
        }
    }
    score3+=s*num;
    // cout << score1 << ' ' << score2 << ' ' << score3 << endl;
    cout << score1+score2+score3 << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3500kb

input:

5
4 5 6 5 5

output:

23

result:

ok single line: '23'

Test #2:

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

input:

13
A 2 3 4 5
6 7 8 9 T
J Q K

output:

71

result:

ok single line: '71'

Test #3:

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

input:

10
2 2 3 4 5 8 9 T J Q

output:

45

result:

ok single line: '45'

Test #4:

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

input:

5
5 5 5 5 J

output:

28

result:

ok single line: '28'

Test #5:

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

input:

5
5 5 5 5 5

output:

40

result:

ok single line: '40'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3504kb

input:

11
A 2 3 5 6 7 8 T J Q K

output:

41

result:

ok single line: '41'

Test #7:

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

input:

20
A 2 3 4 5
A 2 3 4 5
A 2 3 4 5
A 2 3 4 5

output:

20308

result:

ok single line: '20308'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

7
9 6 5 A 4 7 8

output:

16

result:

ok single line: '16'

Test #9:

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

input:

11
Q K
2 2 2
3 3 3
A A
4

output:

226

result:

wrong answer 1st lines differ - expected: '224', found: '226'