This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "coins.h"
#include <vector>
using namespace std;
vector<int> coin_flips(vector<int> b, int c) {
vector<int> v(8);
vector<int> flips;
if(c<2){
if(c==0){
if(b[0]==0)flips.push_back(0);
}
if(c==1){
if(b[0]==1)flips.push_back(0);
else if(v[1]==0)flips.push_back(1);
}
}
if(c>2){
v[0]=1;
for(int i=1;i<8;i++)v[i]=2*v[i-1];
int pos=0;
for(int i=0;i<8;i++){
if(v[7-i]<=c){
pos=1;
c-=v[7-i];
}
else pos=0;
if(b[i]!=pos)flips.push_back(i);
}
}
if(flips.size()==0)flips.push_back(63);
return flips;
}
int find_coin(vector<int> b) {
if(b[0]==1)return 0;
if(b[0]==1||b[1]==1)return 1;
int sol=0;
vector<int> v(8);
v[0]=1;
for(int i=1;i<8;i++)v[i]=2*v[i-1];
for(int i=0;i<8;i++){
if(b[i]==1)sol+=v[7-i];
}
return sol;
}
# | 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... |