QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105147 | #6300. Best Carry Player 2 | Syan | Compile Error | / | / | C++20 | 1.8kb | 2023-05-13 13:25:28 | 2023-05-13 13:25:30 |
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:25:30]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-05-13 13:25:28]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
void ckmin(ll &x, ll y) {
x = min(x, y);
}
const int N = 19;
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], dp[N - 1][k][1]});
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:5:6: error: variable or field ‘ckmin’ declared void 5 | void ckmin(ll &x, ll y) { | ^~~~~ answer.code:5:12: error: ‘ll’ was not declared in this scope 5 | void ckmin(ll &x, ll y) { | ^~ answer.code:5:16: error: ‘x’ was not declared in this scope 5 | void ckmin(ll &x, ll y) { | ^ answer.code:5:19: error: ‘ll’ was not declared in this scope 5 | void ckmin(ll &x, ll y) { | ^~ answer.code:12:1: error: ‘ll’ does not name a type 12 | ll shi[N]; | ^~ answer.code:13:1: error: ‘ll’ does not name a type 13 | ll dp[N][N][2]; | ^~ answer.code: In function ‘void solve(int)’: answer.code:43:25: error: ‘dp’ was not declared in this scope; did you mean ‘dup’? 43 | dp[i][j][0] = dp[i][j][1] = 2e26; | ^~ | dup answer.code:46:9: error: ‘dp’ was not declared in this scope; did you mean ‘dup’? 46 | dp[0][0][0] = 0; | ^~ | dup answer.code:55:33: error: ‘ckmin’ was not declared in this scope 55 | ckmin(dp[i][j][0], dp[i - 1][j][1]); | ^~~~~ answer.code:58:33: error: ‘ll’ was not declared in this scope 58 | ll need = 10 - a; | ^~ answer.code:60:60: error: ‘need’ was not declared in this scope 60 | ckmin(dp[i][j][1], need * shi[i - 1] + dp[i - 1][j - 1][0]); | ^~~~ answer.code:60:67: error: ‘shi’ was not declared in this scope 60 | ckmin(dp[i][j][1], need * shi[i - 1] + dp[i - 1][j - 1][0]); | ^~~ answer.code:60:41: error: ‘ckmin’ was not declared in this scope 60 | ckmin(dp[i][j][1], need * shi[i - 1] + dp[i - 1][j - 1][0]); | ^~~~~ answer.code:62:33: error: ‘need’ was not declared in this scope 62 | need = 9 - a; | ^~~~ answer.code:63:59: error: ‘shi’ was not declared in this scope 63 | ckmin(dp[i][j][1], need * shi[i - 1] + dp[i - 1][j - 1][1]); | ^~~ answer.code:63:33: error: ‘ckmin’ was not declared in this scope 63 | ckmin(dp[i][j][1], need * shi[i - 1] + dp[i - 1][j - 1][1]); | ^~~~~ answer.code:67:9: error: ‘ll’ was not declared in this scope 67 | ll ans = min({dp[N - 1][k][0], dp[N - 1][k][1]}); | ^~ answer.code:67:56: error: expected primary-expression before ‘)’ token 67 | ll ans = min({dp[N - 1][k][0], dp[N - 1][k][1]}); | ^ In file included from /usr/include/c++/11/cassert:44, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:33, from answer.code:1: answer.code:68:16: error: ‘ans’ was not declared in this scope; did you mean ‘abs’? 68 | assert(ans <= 9e18); | ^~~ answer.code: In function ‘int main()’: answer.code:76:9: error: ‘shi’ was not declared in this scope 76 | shi[0] = 1; | ^~~ answer.code: In function ‘void solve(int)’: answer.code:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%s%d", str + 1, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~~~