QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#132417 | #6407. Classical A+B Problem | UFRJ# | WA | 1ms | 3492kb | C++20 | 1.3kb | 2023-07-29 20:44:38 | 2023-07-29 20:44:41 |
Judging History
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'){
for(int k=i;k<n;k++){
if(k + 1 < n && res[k] < '0'){
res[k] += 10;
res[k+1] -= 1;
} else {
break;
}
}
}
if(res[n-1] < '0') break;
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3492kb
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: 3468kb
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)