QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#108010 | #6407. Classical A+B Problem | whatever# | WA | 2ms | 3436kb | C++17 | 1.5kb | 2023-05-23 13:52:11 | 2023-05-23 13:52:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i, a, b) for (int i = (a), I = (b); i <= I; ++i)
#define per(i, a, b) for (int i = (a), I = (b); i >= I; --i)
using i64 = long long;
using pii = pair<int, int>;
template<typename T> void up(T &x, T y) { if (x < y) x = y; }
template<typename T> void down(T &x, T y) { if (x > y) x = y; }
void solve() {
string s;
cin >> s;
reverse(s.begin(), s.end());
int n = s.size();
rep(i, 0, n - 1) s[i] -= '0';
s.push_back(0);
auto check = [&](int x, int a, int y, int b) {
vector<int> t(n + 1);
rep(i, 0, a - 1) t[i] += x;
rep(i, 0, b - 1) t[i] += y;
rep(i, 0, n - 1) t[i + 1] += t[i] / 10, t[i] %= 10;
rep(i, 0, n) if (s[i] != t[i]) return false;
rep(i, 1, a) cout << x;
cout << " ";
rep(i, 1, b) cout << y;
cout << "\n";
return true;
};
rep(x, 1, 9) rep(y, 1, 9) {
if ((x + y) % 10 != s[0]) continue;
int pos = 1;
while (pos < n && s[pos] == s[0] + (x + y >= 10)) ++pos;
if (check(x, pos, y, n - 1)) return;
if (check(x, pos, y, n)) return;
if (check(x, n - 1, y, pos)) return;
if (check(x, n, y, pos)) return;
}
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
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: 2ms
memory: 3432kb
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: 2ms
memory: 3436kb
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 11111111 2222 2 333 2 77777 222222222222222222222 88888888888888888888888888888888888888888888 222222 55555555555555555555 5555555555555555555555 66666666...
result:
wrong answer Token parameter [name=x] equals to "11111111", doesn't correspond to pattern "[1-9]{1,2}" (test case 9)