QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#293043#6300. Best Carry Player 2zxzxzxq#WA 0ms3636kbC++171.7kb2023-12-28 20:42:062023-12-28 20:42:07

Judging History

你现在查看的是最新测评结果

  • [2023-12-28 20:42:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2023-12-28 20:42:06]
  • 提交

answer

#include<bits/stdc++.h>

#define int long long

using namespace std;

const int maxn=55;
int n,a[maxn],k;
int r[maxn];
int ans[maxn],sz[maxn];

void print()
{
    while(ans[n]==0&&n>1) n--;
    for(int i=n;i;i--) 
    {
        cout<<ans[i];
    }
    cout<<'\n';
}

void solve()
{
    int t;
    n=0;
    cin>>t;
    while(t) 
    {
        a[++n]=t%10;
        t/=10;
    }
    // reverse(a+1,a+n+1);
    memset(sz,0,sizeof(sz));
    memset(ans,0,sizeof(ans));
    memset(r,0,sizeof(r));
    cin>>k;
    if(k==0)
    {
        int flag=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]<9) 
            {
                flag=1,ans[i]=1;
                print();
                return ;
            }
        }
        a[++n]=1;
        print();
        return ;
    }
    int looker=1;
    while(a[looker]==0) looker++;
    int ttarget=0;
    if(n-looker+1<k) ttarget=k-(n-looker+1),k=n-looker+1;
    for(int i=n;i;i--) 
    {
        r[i]=i;
        if(a[i+1]==9) r[i]=r[i+1],sz[r[i]]++;
    }
    int target=looker+k-1;
    int nowcnt=0;
    looker+=r[target]-target;
    target=r[target];
    ans[looker]=10-a[looker];
    for(int i=target;i>looker;i--) ans[i]=9-a[i];
    //ans[looker]=10-a[looker];
    //for(int i=looker+1;i<=n&&r[i]!=r[target];i++) ans[i]=9-a[i],nowcnt++;
    //从左边切
    //for(int i=r[target]-(k-nowcnt)+1;i<=r[target];i++) ans[i]=9-a[i];
    while(ttarget) 
    {
        ans[++n]=9;
        ttarget--;
    }
    print();

}

signed main()
{
    ios::sync_with_stdio(false);
    int T;
    cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3636kb

input:

4
12345678 0
12345678 5
12345678 18
990099 5

output:

1
54322
999999999987654322
9910

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3636kb

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
99991000000
9999910000
9999901000
9999900100
9999900010
9999900001
9000009999900001
99000009999900001
999000009999900001
99999999999999999900000000000000000
0

result:

wrong answer 11th lines differ - expected: '10000000001', found: '99991000000'