QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105144 | #6300. Best Carry Player 2 | Syan | Compile Error | / | / | C++20 | 1.8kb | 2023-05-13 13:24:00 | 2023-05-13 13:24:03 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-05-13 13:24:03]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-05-13 13:24:00]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
#define ll __int128
void ckmin(ll &x, ll y) {
x = min(x, y);
}
const int N = 23;
int k;
char str[N];
int bit[N];
ll shi[N];
ll dp[N][N][2];
void solve(int id) {
scanf("%s%d", str + 1, &k);
// if (id == 69) {
// cout << str + 1 << " " << k << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << "\n";
// return;
// }
memset(bit, 0, sizeof bit);
int n = strlen(str + 1);
int m = n;
int zero = 0;
if (k == 0) {
vector<int> ans;
for (int i = n; i >= 0; i --) {
if (i == 0 || str[i] != '9') {
ans.push_back(1);
break;
}
ans.push_back(0);
}
reverse(ans.begin(), ans.end());
for (auto p : ans)
cout << p;
puts("");
return;
}
while (m >= 1 && str[m] == '0') m --, zero ++;
// memset(dp, 0x3f, sizeof dp); // ?? 太小 ??
for (int i = 0; i < N; i ++)
for (int j = 0; j < N; j ++)
dp[i][j][0] = dp[i][j][1] = 2e26;
for (int i = 1, j = m; i <= m; i ++, j --)
bit[i] = str[j] - '0';
dp[0][0][0] = 0;
for (int i = 1; i < N; i ++) {
int a = bit[i];
for (int j = 0; j <= k; j ++) {
// 第 i 位 没有进位
// i - 1 not
dp[i][j][0] = dp[i - 1][j][0];
// i - 1 yes
if (a != 9)
ckmin(dp[i][j][0], dp[i - 1][j][1]);
if (j - 1 >= 0) {
ll need = 10 - a;
if (a != 0)
ckmin(dp[i][j][1], need * shi[i - 1] + dp[i - 1][j - 1][0]);
// i - 1 yes
need = 9 - a;
ckmin(dp[i][j][1], need * shi[i - 1] + dp[i - 1][j - 1][1]);
}
}
}
ll ans = min(dp[N - 1][k][0]);
assert(ans <= 9e18);
printf("%lld", (long long)ans);
for (int i = 0; i < zero; i ++)
printf("0");
puts("");
}
int main() {
shi[0] = 1;
for (int i = 1; i < N; i ++)
shi[i] = shi[i - 1] * 10;
int T;
cin >> T;
for (int i = 1; i <= T; i ++)
solve(i);
}
Details
answer.code: In function ‘void solve(int)’: answer.code:68:21: error: no matching function for call to ‘min(__int128&)’ 68 | ll ans = min(dp[N - 1][k][0]); | ~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/specfun.h:45, from /usr/include/c++/11/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:1: /usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’ 230 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:230:5: note: template argument deduction/substitution failed: answer.code:68:21: note: candidate expects 2 arguments, 1 provided 68 | ll ans = min(dp[N - 1][k][0]); | ~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/specfun.h:45, from /usr/include/c++/11/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:1: /usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 278 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:278:5: note: template argument deduction/substitution failed: answer.code:68:21: note: candidate expects 3 arguments, 1 provided 68 | ll ans = min(dp[N - 1][k][0]); | ~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/string:52, from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)’ 3449 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3449:5: note: template argument deduction/substitution failed: answer.code:68:21: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘__int128’ 68 | ll ans = min(dp[N - 1][k][0]); | ~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/string:52, from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)’ 3455 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3455:5: note: template argument deduction/substitution failed: answer.code:68:21: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘__int128’ 68 | ll ans = min(dp[N - 1][k][0]); | ~~~^~~~~~~~~~~~~~~~~ answer.code:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%s%d", str + 1, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~~~