QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#290169 | #6300. Best Carry Player 2 | zzuqy# | WA | 2066ms | 3956kb | C++14 | 2.9kb | 2023-12-24 15:01:39 | 2023-12-24 15:01:40 |
Judging History
answer
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <set>
#include <map>
#define ll long long
#define db double
#define INF 5000000000000000ll
#define inf 1000000000
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define putl(x) printf("%lld\n",x)
#define rep(p,n,i) for(int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define pii pair<int,int>
#define mk make_pair
#define P 1000000007ll
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define sq sqrt
#define l(w) t[w].l
#define r(w) t[w].r
#define m(w) t[w].m
#define mn(w) t[w].mn
#define c(w) t[w].c
#define s(w) t[w].s
#define tag(w) t[w].tag
#define S second
#define mod 1000000007
#define sc(A) scanf("%d",&A)
#define scs(A) scanf("%s",A);
#define put(A) printf("%d\n",A)
#define zz p<<1
#define yy p<<1|1
#define fep(p,n,cc) for(int cc=p;cc>=n;--cc)
#define scl(A) scanf("%lld",&A)
#define LL __int128
using namespace std;
const int MAXN = 40;
int T;
ll x, k;
int f[MAXN];
int g[MAXN];
LL F[MAXN][MAXN];
LL ans[MAXN];
void wri(LL x) {
if (!x)
return;
wri(x / 10);
putchar(x % 10 + '0');
}
int main() {
//freopen("1.in", "r", stdin);
sc(T);
ans[0] = 1;
while (T--) {
scl(x);
scl(k);
int lim = 37;
rep(0, 37, i) {
g[i] = x % 10;
x /= 10;
if (i >= 1)
ans[i] = ans[i - 1] * 10;
//wri(ans[i]);
//cout << g[i] << endl;
}
//wri(ans[1]);
if (k == 0) {
//cout << "ww" << endl;
rep(0, lim, i) {
if (g[i] != 9) {
wri(ans[i]);
break;
}
}
puts("");
continue;
}
//cout << "ww" << endl;
fep(37, 0, i) {
if (g[i + 1] == 9)
f[i] = f[i + 1] + 1;
else
f[i] = 1;
}
LL ww = 1, bb;
rep(1, lim, i)ww = ww * 10;
rep(0, lim, i)rep(1, 18, j)F[i][j] = ww;
int bv = -1;
rep(0, 38, k)if (g[k]) {
bv = k - 1;
break;
}
fep(lim, 0, i) {
//if(g[i]==0)continue;
if (i <= bv)
continue;
rep(1, lim, j) {
if (j >= f[i]) {
rep(i + f[i] + 1, lim, k) {
if (!g[j - f[i]])
F[i][j] = min(F[i][j], F[k][j - f[i]] + (10 - g[i]) * ans[i]);
}
if (j - f[i] == 0) {
F[i][j] = min(F[i][j], F[i + f[i]][j - f[i]] + (10 - g[i]) * ans[i]);
} else
F[i][j] = min(F[i][j], F[i + f[i]][j - f[i]] + (10 - g[i]) * ans[i] - ans[i + f[i]]);
}
}
}
rep(0, lim, i)if (g[i])
ww = min(ww, F[i][k]);
wri(ww);
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3680kb
input:
4 12345678 0 12345678 5 12345678 18 990099 5
output:
1 54322 999999999987654322 9910
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 3956kb
input:
21 999990000099999 0 999990000099999 1 999990000099999 2 999990000099999 3 999990000099999 4 999990000099999 5 999990000099999 6 999990000099999 7 999990000099999 8 999990000099999 9 999990000099999 10 999990000099999 11 999990000099999 12 999990000099999 13 999990000099999 14 999990000099999 15 999...
output:
100000 10000 1000 100 10 1 900001 9900001 99900001 999900001 10000000001 9999910000 9999901000 9999900100 9999900010 9999900001 9000009999900001 99000009999900001 999000009999900001 99999999999999999900000000000000000 1000000000000000000
result:
ok 21 lines
Test #3:
score: -100
Wrong Answer
time: 2066ms
memory: 3928kb
input:
100000 119111011091190000 10 1911011191011999 16 110099199000119 0 19009911191091011 13 199090909919000900 17 19009010011919110 5 90910190019900091 18 10911100000101111 1 110090011101119990 4 100909999119090000 12 90901119109011100 2 111010119991090101 4 900991019109199009 5 100919919990991119 8 911...
output:
88988908810000 8088988808988001 10 88808908989 9800909090080999100 80890 909089809980099909 9 80010 9090000880910000 8900 9909 991 9008900 8880880090 8080090801 8009900808909899 80880898981 909 8800909 99988889901 89908888089 980908890980099000 100 9889801 81 908890008099900891 880990801 9998099 890...
result:
wrong answer 42nd lines differ - expected: '8989900010', found: '8989900100'