| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1288624 | alexrana2626 | Souvenirs (IOI25_souvenirs) | C++20 | 0 ms | 0 KiB |
#include "souvenirs.h"
#include <bits/stdc++.h>
using namespace std;
void buy_souvenirs(int N, long long P0)
{
pair<vector<int>, long long> res;
if (N == 2)
{
transaction(P0 - 1);
return;
}
if (N == 3)
{
res = transaction(P0 - 1);
long long x = res.second;
if (res.first.size() == 2)
{
transaction((P0 - x - 1) / 2);
return;
}
else
{
long long P1 = P0 - x - 1;
transaction(P1 - 1);
transaction(P1 - 1);
return;
}
}
if (P0 == N)
{
for (int i = 0; i < N; i++)
{
int j = i;
while (j--)
{
transaction(N - i);
}
}
return;
}
else
{
long long sm = n - 2;
for (int i = 1; i < n; i++)
{
long long cnt = i - 1;
if (i == n-1)
{
cnt=sm;
}
res = transaction(P0-1);
long long x = res.second;
if (res.first.size() == 2){sm--;x++;}
long long P = P0 - 1- tt;
P0 = P;
for (int j = 0; j < cnt; j++)
{
transaction(P);
}
}
return;
}
}
