Submission #385268

#TimeUsernameProblemLanguageResultExecution timeMemory
385268IwanttobreakfreeCoins (IOI17_coins)C++17
0 / 100
13 ms1584 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...