QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#325160 | #5607. Cribbage On Steroids | aggrovector# | WA | 1ms | 3620kb | C++14 | 1.6kb | 2024-02-11 05:20:54 | 2024-02-11 05:20:54 |
Judging History
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) {
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;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3504kb
input:
5 4 5 6 5 5
output:
23
result:
ok single line: '23'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
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: 3504kb
input:
10 2 2 3 4 5 8 9 T J Q
output:
45
result:
ok single line: '45'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3620kb
input:
5 5 5 5 5 J
output:
33
result:
wrong answer 1st lines differ - expected: '28', found: '33'