QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#304916#6407. Classical A+B ProblemRaduMWA 8ms145660kbC++231.7kb2024-01-14 06:11:002024-01-14 06:11:01

Judging History

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

  • [2024-01-14 06:11:01]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:145660kb
  • [2024-01-14 06:11:00]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
vector <string> d[10];
bool comp(const string &s1, const string &s2){
    int l1 = s1.size(), l2 = s2.size();
    if(l1 != l2) return l1 < l2;
    while(l1--){
        if(s1[l1] != s2[l1]) return s1[l1] < s2[l1];
    }
    return 0;
}
inline void print(const string &s2){
    for(int i = s2.size() - 1; i >= 0; i--) cout << s2[i];
}
bitset <10> f;
bool subtract(string a, const string &b){
    int n = a.size(), m = b.size(),t = 0,x;
    for(int i = 0; i < n; i++){
        if(i < m) x = (a[i] - b[i]) + t;
        else x = a[i] - '0' + t;
        if(x < 0){
            x += 10;
            t = -1;
        }
        else t = 0;
        a[i] = x + '0';
    }
    f.reset();
    while(n > 1 && a[n - 1] == '0'){
        a.pop_back();
        n--;
    }
    t = 0;
    for(int i = a.size() - 1; i >= 0; i--) f[(a[i] - 48)] = 1;
    for(int i = 1; i <= 9; i++) if(f[i]) t++;
    if(t != 1) return 0;
    print(a);
    cout << " ";
    print(b);
    cout << "\n";
    return 1;
}
void process(string &s){
    int l = s.size(),i;
    while(l){
        for(i = 1; i < 10; i++)
            if(!comp(d[i][l],s)) break;
        i--;
        if(i && subtract(s,d[i][l])) return;
        l--;
    }
}
int main()
{
    int n,i,t;
    string s;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(i = 1; i < 10; i++) d[i].push_back("");
    for(i = 1; i <= 4000; i++)
        for(int j = 1; j < 10; j++) d[j].push_back(d[j][i - 1] + char('0' + j));
    cin >> t;
    for(int e = 1; e <= t; e++){
        cin.get();
        cin >> s;
        reverse(s.begin(), s.end());
        process(s);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 145592kb

input:

6
2
786
1332
89110
2333333
10000000000000000000000000001

output:

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

result:

ok ok (6 test cases)

Test #2:

score: -100
Wrong Answer
time: 8ms
memory: 145660kb

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
6 44444444
222 11111111111111111
88 2222
1 4
9999 333333333333333333333333333
111 888888
1 9
2222 11111111
2 333
2 77777
222222222222222222222 88888888888888888888888888888888888888888888
222222 55555555555555555555
5555555555555555555555 6666...

result:

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