/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 21ms 24.27 MiB
#2 Accepted 48ms 24.281 MiB
#3 Accepted 625ms 24.32 MiB
#4 Accepted 97ms 24.281 MiB
#5 Accepted 74ms 24.414 MiB
#6 Accepted 29ms 24.27 MiB
#7 Accepted 656ms 24.426 MiB
#8 Accepted 20ms 24.367 MiB
#9 Accepted 20ms 24.348 MiB
#10 Accepted 20ms 24.27 MiB
#11 Accepted 20ms 24.27 MiB
#12 Accepted 29ms 24.426 MiB
#13 Accepted 108ms 24.27 MiB
#14 Accepted 27ms 24.27 MiB
#15 Accepted 23ms 24.34 MiB
#16 Accepted 99ms 24.43 MiB
#17 Accepted 34ms 24.223 MiB
#18 Accepted 32ms 24.344 MiB
#19 Accepted 166ms 24.387 MiB
#20 Accepted 200ms 24.352 MiB
#21 Accepted 67ms 24.34 MiB
#22 Accepted 49ms 24.27 MiB
#23 Accepted 35ms 24.27 MiB
#24 Accepted 20ms 24.27 MiB
#25 Accepted 31ms 24.227 MiB
#26 Accepted 33ms 24.391 MiB
#27 Accepted 116ms 24.375 MiB
#28 Accepted 20ms 24.41 MiB
#29 Accepted 21ms 24.391 MiB
#30 Accepted 21ms 24.223 MiB
#31 Accepted 46ms 24.277 MiB
#32 Accepted 21ms 24.324 MiB
#33 Accepted 25ms 24.27 MiB
#34 Accepted 24ms 24.27 MiB
#35 Accepted 26ms 24.312 MiB
#36 Accepted 31ms 24.27 MiB
#37 Accepted 24ms 24.344 MiB
#38 Accepted 27ms 24.426 MiB
#39 Accepted 30ms 24.27 MiB

Code

/*One touch and i IGNITE*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define endl "\n"
#define Endl "\n"

const int N = 2e5 + 5;
int tc, n, casee = 1, a, b, c, d;
int dp[50][50][50][50];

struct R {
    int a, b, c, d;
};

vector<R> v;

void buildBaseCase() {
    /// this is --a, b, c, d
    v.push_back({0, 0, 1, 2});
    v.push_back({0, 0, 3, 0});
    v.push_back({0, 3, 0, 1});
    v.push_back({0, 3, 1, 0});
    v.push_back({1, 1, 0, 2});
    v.push_back({1, 1, 1, 1});
    v.push_back({1, 1, 2, 0});
    v.push_back({1, 4, 0, 0});
    v.push_back({2, 2, 0, 1});
    v.push_back({2, 2, 1, 0});
    v.push_back({3, 0, 0, 2});
    v.push_back({3, 0, 1, 1});
    v.push_back({3, 0, 2, 0});
    v.push_back({3, 3, 0, 0});
    v.push_back({4, 1, 0, 1});
    v.push_back({4, 1, 1, 0});
    v.push_back({5, 2, 0, 0});
    v.push_back({6, 0, 0, 1});
    v.push_back({6, 0, 1, 0});
    v.push_back({7, 1, 0, 0});
    v.push_back({9, 0, 0, 0});
}

int rec(int a, int b, int c, int d) {

    bool notPossible = true;
    for (auto i : v) {
        if (i.a <= a && i.b <= b && i.c <= c && i.d <= d) {
            notPossible = false;
            break;
        }
    }
    if (notPossible)
        return 0;
    int &ret = dp[a][b][c][d];
    if (~ret)
        return ret;
    ret = 0;

    for (auto i : v) {
        if (i.a <= a && i.b <= b && i.c <= c && i.d <= d) {
            ret = max(ret, 1 + rec(a - i.a, b - i.b, c - i.c, d - i.d));
        }
    }

    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); // cout.tie(0);
    // freopen("Input/input37.txt", "r", stdin);
    // freopen("Output/output37.txt", "w", stdout);
    buildBaseCase();
    cin >> tc;
    while (tc--) {
        cin >> a >> b >> c >> d;
        memset(dp, -1, sizeof dp);
        int Ans = rec(a, b, c, d);
        cout << "Case " << casee++ << ": " << Ans << endl;
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1014 FIFA World Cup 2022 Again!
Language
C++17 (G++ 13.2.0)
Submit At
2025-01-15 12:22:20
Judged At
2025-01-15 12:29:44
Judged By
Score
100
Total Time
656ms
Peak Memory
24.43 MiB