| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1285616 | ecen30 | Souvenirs (IOI25_souvenirs) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
//This is Grok 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.
pair<vector<int>, long long> transaction(long long M);
void buy_souvenirs(int N, long long P0) {
vector<long long> P(N);
P[0] = P0;
// Step 1: Discover all prices P[1], P[2], ..., P[N-1] using binary search
for (int i = 1; i < N; ++i) {
long long low = 1;
long long high = P[i - 1] - 1;
long long found = -1;
while (low <= high) {
long long mid = low + (high - low) / 2;
auto [types, remaining] = transaction(mid);
// Check if we got any type >= i
bool got_high = false;
for (int t : types) {
if (t >= i) {
got_high = true;
break;
}
}
if (got_high) {
// P[i] <= mid
found = mid;
high = mid - 1;
} else {
// P[i] > mid
low = mid + 1;
}
}
P[i] = found;
}
// Step 2: Buy exactly i souvenirs of type i (for i = 1 to N-1)
// Using transaction(P[i]) exactly i times gives exactly one type i each time
for (int i = 1; i < N; ++i) {
for (int cnt = 0; cnt < i; ++cnt) {
transaction(P[i]);
}
}
}
