Submission #1290816

#TimeUsernameProblemLanguageResultExecution timeMemory
1290816ecen30Souvenirs (IOI25_souvenirs)C++20
0 / 100
13 ms388 KiB
//testing AI code
#include <vector>
#include <cstdio>
using namespace std;

// Provided by the judge:
extern std::pair<std::vector<int>, long long> transaction(long long M);

void buy_souvenirs(int N, long long P0) {
    std::vector<long long> prices(N, -1);
    prices[0] = P0;

    // Step 1: Discover unknown prices.
    // For M = 1 to P0 - 1, run transaction and map which souvenir you get for each M.
    int found = 1;
    for (long long m = 1; m < P0; ++m) {
        auto res = transaction(m);
        for(int type : res.first) {
            if(type != 0 && prices[type] == -1) {
                prices[type] = m;
                ++found;
            }
        }
        if(found == N) break; // All found
    }

    // Step 2: For each souvenir type i=1..N-1, buy exactly i of type i.
    std::vector<int> Q(N, 0);
    for(int i = 1; i < N; ++i) {
        for(int k = 0; k < i; ++k) {
            auto res = transaction(prices[i]);
            for(int t : res.first) {
                if(t==i) ++Q[i];
            }
        }
    }

    // Output results for grader
    for(int i=0; i<N; ++i) {
        printf("%d%c", Q[i], " \n"[i+1==N]);
    }
}


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...