QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#132414#6407. Classical A+B ProblemUFRJ#WA 1ms3580kbC++201.3kb2023-07-29 20:37:012023-07-29 20:37:05

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-29 20:37:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3580kb
  • [2023-07-29 20:37:01]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

void solve(){
    string s;
    cin>>s;
    int n = int(s.size());
    reverse(s.begin(), s.end());
    int last0 = n;
    for(int j=1;j<10;j++){
        string t;
        t.reserve(n);
        string res = s;
        for(int i=0;i<n; i++){
            t += char('0' + j);
            res[i] += - t[i] + '0';
            if(i + 1 < n && res[i] < '0'){
                res[i] += 10;
                res[i+1] -= 1;
                for(int k=i;k<n;k++){
                    if(k + 1 < n && res[k] < '0'){
                        res[k] += 10;
                        res[k+1] -= 1;
                    }
                }
            }
            while(last0 > 0 && res[last0-1] == '0'){
                last0--;
            }
            if(last0 == 0) break;
            int cnt = 0;
            for(int i = 0; i<last0; i++)
                if(res[i] == res[0])
                    cnt++;
            if(cnt == last0){
                res.resize(last0);
                cout<<t<<" "<<res<<"\n";
                return;
            }
        }
    }
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3580kb

input:

6
2
786
1332
89110
2333333
10000000000000000000000000001

output:

1 1
777 9
333 999
222 88888
111111 2222222
2 9999999999999999999999999999

result:

ok ok (6 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3524kb

input:

100
854
77777777781111111111111111110
44444450
11111111111111333
2310
5
333333333333333333333343332
888999
10
11113333
335
77779
88888888888888888888889111111111111111111110
55555555555555777777
72222222222222222222221
666
5777
1111555555
444444444544444444443
88888888888891111111111110
673332
97
77...

output:

77 777
3333333333333333333 77777777777777777777777777777
44444444 6
11111111111111111 222
2222 88
1 4
333333333333333333333333333 9999
111 888888
1 9
11111111 2222
2 333
2 77777
222222222222222222222 88888888888888888888888888888888888888888888
222222 55555555555555555555
5555555555555555555555 6666...

result:

wrong answer Token parameter [name=x] equals to "8888888", doesn't correspond to pattern "[1-9]{1,2}" (test case 77)