QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#244396#7041. Girls Band PartyMoustafaAC ✓566ms25276kbC++142.8kb2023-11-09 01:17:172023-11-09 01:17:17

Judging History

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

  • [2023-11-09 01:17:17]
  • 评测
  • 测评结果:AC
  • 用时:566ms
  • 内存:25276kb
  • [2023-11-09 01:17:17]
  • 提交

answer

#include "bits/stdc++.h"

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#define endl            "\n"
#define all(v)          v.begin(), v.end()
#define debug(x)        cout << #x << " is " << x << endl
#define clr(x, value)    memset(x, value, sizeof(x))
#define Unique(x)       x.erase(unique(all(x)), x.end())

using namespace std;
using ll = long long;

const int N = 1e5 + 5;
ll dp[N][6][6][6], n, id;
int vis[N][6][6][6];
map<string, pair<int, int>> mp;
vector<string> goodNames;
string goodColor;
vector<string> names;

ll go(int i, int took, int wantName, int wantColor) {
    if (min(wantColor, wantName) < 0) return -1e15;
    if (took == 5) return (wantColor + wantName ? -1e15 : 0);
    if (i == mp.size()) return -1e15;

    ll &ret = dp[i][took][wantName][wantColor];
    if (vis[i][took][wantName][wantColor] == id) return ret;

    vis[i][took][wantName][wantColor] = id;

    ret = go(i + 1, took, wantName, wantColor);
    bool goodName = binary_search(goodNames.begin(), goodNames.end(), names[i]);
    auto p = mp[names[i]];
    bool isGoodColor = p.first;
    if (p.first)
        ret = max(ret, p.first + go(i + 1, took + 1,
                                    wantName - goodName, wantColor - isGoodColor));

    if (p.second)
        ret = max(ret, p.second + go(i + 1, took + 1,
                                    wantName - goodName, wantColor));
    return ret;
}

struct card {
    string name, color;
    int power;

    card(string name, string color, int power) :
            name(name), color(color), power(power) {

    }
};

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);

    int TC;
    cin >> TC;
    while (TC--) {
        cin >> n;
        id++;

        mp.clear();
        names.clear();

        vector<card> cards;

        for (int i = 0; i < n; ++i) {
            string name, color;
            int power;
            cin >> name >> color >> power;
            cards.emplace_back(name, color, power);
            names.push_back(name);
        }

        sort(all(names));
        Unique(names);

        goodNames.resize(5);
        for (int i = 0; i < 5; ++i) {
            cin >> goodNames[i];
        }
        sort(all(goodNames));

        cin >> goodColor;

        for (int i = 0; i < n; ++i) {
            auto [name, color, power] = cards[i];
            if (color == goodColor) mp[name].first = max(mp[name].first, power);
            else mp[name].second = max(mp[name].second, power);
        }

        ll mx = 0;
        for (int i = 0; i <= 5; ++i) {
            for (int j = 0; j <= 5; ++j) {
                ll cur = i * 10 + j * 20;
                ll ans = (1 + cur / 100.0) * go(0, 0, i, j);
                mx = max(mx, ans);
            }
        }
        cout << mx << endl;
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
6
Saaya Power 45000
Kokoro Happy 45000
Kasumi Cool 45000
Rimi Power 45000
Aya Pure 45000
Aya Power 2000
Saaya Tae Kasumi Rimi Arisa
Power

output:

382500

result:

ok 1 number(s): "382500"

Test #2:

score: 0
Accepted
time: 566ms
memory: 24360kb

input:

50
6
Tae Pure 13573
Chisato Happy 48889
Hina Power 36087
Kasumi Cool 5878
Rimi Power 21091
Rinko Cool 21035
Eve Tomoe Sayo Saya Tsugumi
Power
8
Hina Power 33669
Kokoro Happy 48080
Tsugumi Cool 37215
Lisa Power 22671
Kaoru Pure 3556
Hagumi Happy 26536
Rimi Power 20561
Maya Power 29893
Kaoru Chisato H...

output:

196945
265697
185972
181747
190528
187408
110113
238308
223522
233073
561365
531401
474005
604145
393206
497631
598267
535132
404644
501993
623480
525683
623575
624482
624315
624057
624042
536709
624202
623755
622960
622482
624082
623832
623182
622470
618160
623535
624680
622372
624385
623042
622857...

result:

ok 50 numbers

Test #3:

score: 0
Accepted
time: 539ms
memory: 25276kb

input:

50
6
Rinko Cool 29445
Sayo Power 33447
Rimi Power 47202
Rinko Power 13982
Himari Power 2156
Moca Cool 45728
Kaoru Moca Hagumi Aya Kanon
Happy
10
Misaki Pure 11868
Maya Pure 46263
Aya Power 36991
Tsugumi Happy 27068
Tomoe Pure 41757
Aya Cool 44328
Saaya Happy 46221
Arisa Cool 31545
Kanon Happy 25467
...

output:

173775
321889
151163
255470
234021
199576
223339
262045
193091
225840
169657
191240
192443
222483
96308
184369
341478
181268
166455
258093
620735
610022
617712
623135
622237
623880
614360
622132
623332
623607
620665
618695
623477
619787
621477
623012
618887
616462
623855
622627
623852
624200
624540
...

result:

ok 50 numbers