제출 #780866

#제출 시각아이디문제언어결과실행 시간메모리
780866Josia비스킷 담기 (IOI20_biscuits)C++17
0 / 100
2 ms340 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define int long long long long count_tastiness(long long x, std::vector<long long> a) { vector<int> b(100, 0); int carry = 0; for (int i = 0; i<b.size(); i++) { carry /= 2; int here = carry+(i<a.size()?a[i]:0); if (here == 0) continue; if (here%2==0) { b[i] = 2; carry = here - 2; } else { b[i] = 1; carry = here - 1; } } // for (int i: b) cerr << i << " "; // cerr << "\n"; int res = 1; bool cont = 1; int lastCont = 0; int addup = 0; for (int i=0; i<62; i++) { if (!b[i]) {cont = 0; lastCont = 0; res += addup; addup = 0; continue;} if (b[i]) {cont = 1;} res *= 2; if (b[i] == 2) addup += 1<<lastCont; lastCont ++; } res += addup; return res; }

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

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:14:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int i = 0; i<b.size(); i++) {
      |                  ~^~~~~~~~~
biscuits.cpp:17:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   int here = carry+(i<a.size()?a[i]:0);
      |                     ~^~~~~~~~~
biscuits.cpp:37:7: warning: variable 'cont' set but not used [-Wunused-but-set-variable]
   37 |  bool cont = 1;
      |       ^~~~
#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...