Submission #385269

#TimeUsernameProblemLanguageResultExecution timeMemory
385269IwanttobreakfreeCoins (IOI17_coins)C++17
25 / 100
14 ms1796 KiB
#include "coins.h" #include <iostream> #include <vector> using namespace std; vector<int> coin_flips(vector<int> b, int c) { vector<int> v(8); vector<int> flips; 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[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...