QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#325237#5607. Cribbage On Steroidsweilaifuture#WA 1ms3688kbC++141.3kb2024-02-11 06:12:012024-02-11 06:12:01

Judging History

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

  • [2024-02-11 06:12:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3688kb
  • [2024-02-11 06:12:01]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n, cnt[15],dp[105][20];
long long ans;
char s[105];
int num(char a){
    if(a=='A') return 1;
    else if(a=='T'||a=='J'||a=='Q'||a=='K') return 10;
    else return a-'0';
}
void fif(){
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=15;j>=num(s[i]);j--){
            dp[i][j]+=dp[i-1][j-num(s[i])];
        }
        for(int j=15;j>=0;j--) dp[i][j] += dp[i-1][j];
    }
    ans += 2 * dp[n][15];
}
int num1(char a){
    if(a=='A') return 1;
    else if(a=='T') return 10;
    else if(a=='J') return 11;
    else if(a=='Q') return 12;
    else if(a=='K') return 13;
    else return a-'0';
}
void pairs(){
    long long tmp=0;
    for(int i=1;i<=n;i++) cnt[num1(s[i])]++;
    for(int i=1;i<=13;i++) if(cnt[i]) tmp += cnt[i]*(cnt[i]-1);
    ans+= tmp;
}
void runs(){
    int curr=1; long long tmp=0,tmp1=0,tmp2=0;
    while(curr <= 13){
        if(cnt[curr] == 0){if(tmp2>=3) tmp += tmp1*tmp2; tmp1=0; tmp2=0;}
        else{
            if(tmp1==0) tmp1=cnt[curr],tmp2=1;
            else tmp1*=cnt[curr],tmp2++;
        }
        curr++;
    }
    if(tmp2>=3) tmp+=tmp1*tmp2; ans+=tmp;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>s[i];
    fif();
    pairs(); runs();
    cout<<ans;
    return 0;
}

詳細信息

Test #1:

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

input:

5
4 5 6 5 5

output:

23

result:

ok single line: '23'

Test #2:

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

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: 1ms
memory: 3668kb

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: 1ms
memory: 3624kb

input:

5
5 5 5 5 J

output:

28

result:

ok single line: '28'

Test #5:

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

input:

5
5 5 5 5 5

output:

40

result:

ok single line: '40'

Test #6:

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

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: 3620kb

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

input:

7
9 6 5 A 4 7 8

output:

16

result:

ok single line: '16'

Test #9:

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

input:

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

output:

224

result:

ok single line: '224'

Test #10:

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

input:

100
A A A A A A A A A A A A A A A A A A A A
A A A A A A A A A A A A A A A A A A A A
A A A A A A A A A A A A A A A A A A A A
A A A A A A A A A A A A A A A A A A A A
A A A A A A A A A A A A A A A A A A A A

output:

-1316781844

result:

wrong answer 1st lines differ - expected: '506676942699987180', found: '-1316781844'