QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#780741#9549. The MagicianyimgWA 0ms3628kbC++202.7kb2024-11-25 12:55:292024-11-25 12:55:41

Judging History

This is the latest submission verdict.

  • [2024-11-27 17:55:10]
  • hack成功,自动添加数据
  • (/hack/1262)
  • [2024-11-26 22:59:39]
  • hack成功,自动添加数据
  • (/hack/1259)
  • [2024-11-25 12:55:41]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3628kb
  • [2024-11-25 12:55:29]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
void work()
{
    int n;
    cin >> n;
    map<char, int> cnt;
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        cnt[s[1]]++;
    }
    vector<int> t(10);
    for(int i = 1; i <= 6; ++i) cin >> t[i];
    int ans = 0;
    ans += cnt['D'] / 5;
    ans += cnt['C'] / 5;
    ans += cnt['H'] / 5;
    ans += cnt['S'] / 5;
    cnt['D'] %= 5;
    cnt['C'] %= 5;
    cnt['H'] %= 5;
    cnt['S'] %= 5;
    // cout << ans << "\n";
    int beg = ans;
    vector<char> mp(10);
    int ct = t[5] + t[6];
    mp[1] = 'D'; mp[2] = 'C'; mp[3] = 'H'; mp[4] = 'S';
    auto dfs = [&](auto &&self, int d, int tmp) -> void
    {
        // if(tmp == 2){
        //     cout << " HHH : " << d << "\n";
        // }
        if (d == 5)
        {
            vector<int> a;
            a.push_back(cnt['D']);
            a.push_back(cnt['C']);
            a.push_back(cnt['H']);
            a.push_back(cnt['S']);
            sort(a.begin(), a.end(), greater<int>());
            // for(auto i : a){
            //     cout << i << " ";
            // }
            // cout << "\n";
            int tt = ct;
            if(tt && a[0] >= 4){
                tt--;
                a[0] = 0;
                tmp++;
            }
            if(tt && a[1] >= 4){
                tt--;
                a[1] = 0;
                tmp++;
            }
            if (tt == 2 && a[0] >= 3){
                tt = 0; a[0] = 0;
                tmp++;
            }
            int sum = 0;
            bool flag = 0;
            for(int i = 0; i < 4; ++i) sum += a[i], flag |= t[i + 1];
            if(sum >= 5 && flag && tt == 2) tmp++; 
            // cout << sum << " " << flag << " " << tmp << "\n";
            ans = max(ans, tmp);
            return;
        }
        if (!t[d])
        {
            
            self(self, d + 1, tmp);
        }
        else
        {
            self(self, d + 1, tmp);
            
            // cout << "LLL : " << tmp << "\n";
            for(int i = 1; i <= 4; ++i){
                if(i == d) continue;
                if(cnt[i] >= 2  && cnt[mp[d]] + cnt[mp[i]] >= 5){
                    int log = cnt[mp[d]];
                    cnt[mp[d]] = 0;
                    cnt[mp[i]] -= 5 - log;
                    t[d] = 0;
                    self(self, d + 1, tmp + 1);
                    cnt[mp[d]] = log;
                    cnt[mp[i]] += 5 - log; 
                    t[d] = 1;
                }

            }
        }
    };
    dfs(dfs, 1, beg);
    cout << ans << "\n";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
        work();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3628kb

input:

4
5
2H 3H 4H 5H 6D
1 1 1 1 0 0
5
2S 3S 4D 5C 6D
0 0 1 0 1 1
5
2S 3S 4D 5C 6D
0 0 1 0 1 0
13
AS 2S 3S 4S 5H 6H 7H 8H 9H TH JH QH KH
0 0 0 0 0 1

output:

0
1
0
2

result:

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