| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1285244 | ecen30 | Souvenirs (IOI25_souvenirs) | C++20 | 0 ms | 0 KiB |
//This is ChatGPT code. I am using this website to test different AI's and their abilities to solve IOI problems. Please understand. I do not mean to cheat. Just trying to get a good grade on my science project.
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
// Simulate the transaction function provided by the grader
pair<vector<int>, long long> transaction(long long M) {
// This function is supposed to be provided by the grader
// Here, it's just a placeholder to illustrate how it works
return {{}, M}; // Return a dummy value (to be implemented by the grader)
}
void buy_souvenirs(int N, long long P0) {
// We need to determine the price of each souvenir P[0], P[1], ..., P[N-1]
vector<long long> prices(N, 0);
prices[0] = P0; // The price of the first souvenir is known
// Guess the price for the remaining souvenirs using a binary search strategy
// Start with a reasonable guess for each price and refine it with each transaction
// Let's assume the minimum price is 1 for the cheapest souvenir
long long min_price = 1;
long long max_price = P0 - 1;
// Deduce the price for each souvenir
for (int i = 1; i < N; i++) {
long long current_guess = (max_price + min_price) / 2;
// Perform a transaction with the current guess
auto [L, R] = transaction(current_guess);
// Deduce the price based on the returned souvenirs
if (R == 0) {
prices[i] = current_guess;
}
// Adjust the guess based on whether the price is too high or too low
if (R > 0) {
min_price = current_guess + 1;
} else {
max_price = current_guess - 1;
}
}
// Now that we know the prices, let's simulate the actual buying of souvenirs
vector<int> souvenirs_count(N, 0);
long long remaining_coins = 0;
// Simulate the transaction process to ensure we buy exactly i souvenirs of type i
for (int i = 1; i < N; i++) {
// Perform transactions to buy the correct number of souvenirs
long long coins_needed = prices[i] * (i + 1);
auto [L, R] = transaction(coins_needed);
souvenirs_count[i] += L.size();
remaining_coins = R;
}
// Output the result
for (int i = 0; i < N; i++) {
cout << souvenirs_count[i] << " ";
}
cout << endl;
}
