#include "souvenirs.h"
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse2")
#define ll long long
#define db double
#define ld long double
#define endl '\n'
#define eb emplace_back
#define em emplace
#define pb push_back
#define pf push_front
#define pp pop_back
#define fr first
#define sc second
#define sz size
#define ir insert
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define all(x) x.begin() , x.end()
#define alice cout << "Alice" << endl
#define bob cout << "Bob" << endl
#define fo(x , y) for(ll i = x;i < y;i++)
using namespace std;
void buy_souvenirs(int N, ll P0) {
if(N==2){transaction(P0-1) ;return;}
if(N==3){
auto x=transaction(P0-1);
if(x.fr.sz()==1){ll vl=P0-1-x.sc; transaction(vl-1);transaction(vl-1);}
else{ll vl= (P0-1-x.sc) ; vl+=(2-vl%2)%2;vl/=2; transaction(vl-1);}
return;
}
vector<ll>cn(N,0) , vl(N);
vl[0]=P0;
for(int i =1;i < N;i++) {
auto x =transaction(vl[i-1] - 1) ;
for(int y: x.fr) cn[y]++;
if(x.fr.sz() ==1) vl[i] = vl[i-1] - 1 -x.sc;
else vl[i] = vl[i-1] - 2;
}
for(int i = 1; i<N;i++) {
while(cn[i] <i) {
transaction(vl[i]);
cn[i]++;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |