제출 #933868

#제출 시각아이디문제언어결과실행 시간메모리
933868guymmkCoins (IOI17_coins)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include "vector" using namespace std; vector<int> coin_flips(vector<int> a,int c){ string bit; if (c == 0) bit="0"; while (c > 0) { if (c%2==0) bit += '0'; else bit += '1'; c = c >> 1; } reverse(bit.begin(), bit.end()); 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){ string s; for(int i=0;i<6;i++)s+=(char)(a[i]+'0'); 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; }

컴파일 시 표준 에러 (stderr) 메시지

coins.cpp: In function 'std::vector<int> coin_flips(std::vector<int>, int)':
coins.cpp:13:5: error: 'reverse' was not declared in this scope
   13 |     reverse(bit.begin(), bit.end());
      |     ^~~~~~~
coins.cpp: In function 'int find_coin(std::vector<int>)':
coins.cpp:28:5: error: 'reverse' was not declared in this scope
   28 |     reverse(s.begin(), s.end());
      |     ^~~~~~~
coins.cpp:30:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0 ; i < s.size() ; i++, cur_pow *= 2) {
      |                      ~~^~~~~~~~~~