#include "coins.h"
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
vector<int> coin_flips(vector<int> b, int c) {
int dplus = 0;
int dminu = 0;
int hash = 0;
for (int& e : b)
if (e == 0)
dplus++;
else
dminu++, hash++;
hash %= 64;
if (c == hash)
// nice
return b;
else {
int ansplus = hash - c;
if (ansplus < 0)
ansplus += 64;
if (ansplus < dplus) {
vector <int> ans;
for (int i = 0; i <= 63; i++)
if (b[i] == 0 && ansplus) {
ans.emplace_back (i);
ansplus--;
}
return ans;
}
int ansminu = c - hash;
if (ansminu < 0)
ansminu += 64;
if (ansminu < dminu) {
vector <int> ans;
for (int i = 0; i <= 63; i++)
if (b[i] == 1 && ansminu) {
ans.emplace_back (i);
ansminu--;
}
return ans;
}
// ?
exit (1);
}
}
int find_coin(vector<int> b) {
int hash = 0;
for (int& e : b)
if (e == 1)
hash++;
return (hash + 64) % 64;
}
# | 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... |