QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#681379#5607. Cribbage On Steroidsvic233333#WA 0ms3828kbC++202.8kb2024-10-27 06:26:122024-10-27 06:26:12

Judging History

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

  • [2024-10-27 06:26:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3828kb
  • [2024-10-27 06:26:12]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define pb push_back

const ld pi = 3.14159265358979323846;
const int mod = 998244353;
const ll INF = 1e18;

template<typename T>
T chmax(T a, T b) {
    return a > b ? a : b;
}

template<typename T>
T chmin(T a, T b) {
    return a > b ? b : a;
}

const int N = (int)1e4 + 1, M = N * 2;

void solve() {
    int n;
    cin >> n;

    vector<int> a, ap;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;

        if (c == 'T' || c == 'J' || c == 'Q' || c == 'K') a.pb(10);
        else if (c == 'A') a.pb(1);
        else a.pb(c - '0');

        if(c == 'A') ap.pb(1);
        else if(c == 'T') ap.pb(10);
        else if(c == 'J') ap.pb(11);
        else if(c == 'Q') ap.pb(12);
        else if(c == 'K') ap.pb(13);
        else ap.pb(c - '0');
    }

    map<int, int> mp;
    for(int i = 0; i < a.size(); i++){
        mp[ap[i]]++;
    }

    sort(a.begin(), a.end());
    sort(ap.begin(), ap.end());

    auto get15= [&]() -> ll{
        ll f[16];
        memset(f, 0, sizeof f);

        f[0] = 1;
        for(int i = 0; i < a.size(); i++){
            for(int j = 15; j >= a[i]; j--){
                f[j] += f[j - a[i]];
            }
        }
        return f[15] * 2;
    };

    auto pairs = [&]() -> ll{
        ll qwq = 0;
        for(int i = 1; i <= 10; i++){
            if(mp[i] >= 2){
                qwq += mp[i] * 1ll * (mp[i] - 1);
            }
        }
        return qwq;
    };

    auto runs = [&]() -> ll{
        ll qwq = 0;
        vector<vector<int>> b;
        for(int i = 0; i < a.size(); i++){
            if(b.empty() || b.back()[0] != ap[i]){
                b.pb({ap[i], 1});
            }
            else{
                b.back()[1]++;
            }
        }

        ll owo = 1, c = 0;
        for(int i = 0; i < b.size(); i++){
            if(i){
                if(b[i][0] - b[i - 1][0] != 1){
                    if(c > 2){
                        qwq += owo * c;
                    }
                    c = 1;
                    owo = b[i][1];
                }
                else{
                    c++;
                    owo *= b[i][1];
                }
            }
            else{
                owo = b[i][1];
                c++;
            }
        }
        if(c > 2){
            qwq += owo * c;
        }
        return qwq;
    };
    
    cout << get15() + pairs() + runs() << endl;
}

int main() {
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    //    cin >> t;

    while(t--){
        solve();
    }

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

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

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

input:

5
5 5 5 5 J

output:

28

result:

ok single line: '28'

Test #5:

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

input:

5
5 5 5 5 5

output:

40

result:

ok single line: '40'

Test #6:

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

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

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

input:

7
9 6 5 A 4 7 8

output:

16

result:

ok single line: '16'

Test #9:

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

input:

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

output:

224

result:

ok single line: '224'

Test #10:

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

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:

506676942699987180

result:

ok single line: '506676942699987180'

Test #11:

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

input:

100
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5

output:

333300

result:

ok single line: '333300'

Test #12:

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

input:

5
K J 2 6 8

output:

0

result:

ok single line: '0'

Test #13:

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

input:

7
T J J J Q K K

output:

24

result:

wrong answer 1st lines differ - expected: '32', found: '24'