Submission #933684

#TimeUsernameProblemLanguageResultExecution timeMemory
933684guymmkCoins (IOI17_coins)C++14
0 / 100
2 ms1120 KiB
#include "bits/stdc++.h" using namespace std; string to_binary (int x) { string ret; if (x == 0) return "0"; while (x > 0) { if (x%2==0) ret += '0'; else ret += '1'; x = x >> 1; } reverse(ret.begin(), ret.end()); return ret; } int to_decimal (string s) { int x = 0; reverse(s.begin(), s.end()); int cur_pow = 1; for (int i = 0 ; i < s.size() ; i++, cur_pow *= 2) { x += cur_pow * (s[i] == '1'); } return x; } vector<int> coin_flips(vector<int> a,int c){ string bit= to_binary(c); cout<<bit<<endl; reverse(bit.begin(),bit.end()); vector<int>res; while(bit.size()!=6)bit='0'+bit; for(int i=0;i<6;i++){ if(bit[i]-'0'!=a[i])res.push_back(i); } return res; } int find_coin(vector<int>a){ int ans; string s; for(int i=0;i<6;i++)s+=(char)(a[i]+'0'); ans= to_decimal(s); return ans; }

Compilation message (stderr)

coins.cpp: In function 'int to_decimal(std::string)':
coins.cpp:21:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for (int i = 0 ; i < s.size() ; i++, cur_pow *= 2) {
      |                      ~~^~~~~~~~~~
#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...