이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include <bits/stdc++.h>
#ifdef local
#define debug(x...) qqbx(#x, x)
template <typename ...T> void qqbx(const char *s, T ...args) {
int cnt = sizeof...(T);
((std::cerr << "\e[1;32m(" << s << ") = (") , ... , (std::cerr << args << (--cnt ? ", " : ")\e[0m\n")));
}
#else
#define debug(...) ((void)0)
#endif
using namespace std;
const int maxn = 65;
map<long long, long long> dp[maxn];
int cnt = 0;
long long dfs(vector<long long> &a, long long x, int i, long long carry) {
if (i == a.size()) {
return carry / x + 1;
}
++cnt;
if (dp[i].count(carry))
return dp[i][carry];
long long &res = dp[i][carry];
carry += a[i];
res += dfs(a, x, i+1, carry / 2); // y >> i & 1 == 0
if (carry >= x) {
res += dfs(a, x, i+1, (carry - x) / 2);
}
return res;
}
long long count_tastiness(long long x, std::vector<long long> a) {
for (int i = 0; i < a.size(); i++) dp[i].clear();
for (int i = 0; i+1 < a.size(); i++) {
if (a[i] >= x) {
long long diff = (a[i] - x) / 2;
a[i] -= diff * 2;
a[i+1] += diff;
}
}
long long res = dfs(a, x, 0, 0);
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
biscuits.cpp: In function 'long long int dfs(std::vector<long long int>&, long long int, int, long long int)':
biscuits.cpp:18:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | if (i == a.size()) {
| ~~^~~~~~~~~~~
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int i = 0; i < a.size(); i++) dp[i].clear();
| ~~^~~~~~~~~~
biscuits.cpp:34:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for (int i = 0; i+1 < a.size(); i++) {
| ~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |