QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#626768 | #7897. Largest Digit | adivse# | WA | 3ms | 3816kb | C++20 | 2.4kb | 2024-10-10 12:43:49 | 2024-10-10 12:43:49 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#define endl '\n'
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define rep2(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
template<typename... Args>
void bubu(Args... args) { cout << ":: "; ((cout << args << " "), ...); cout << endl; }
void bubu(vector<int> tem) { for (auto x : tem) cout << x << ' '; cout << endl; }
void kuaidu() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); }
inline int max(int a, int b) { if (a < b) return b; return a; }
inline int min(int a, int b) { if (a < b) return a; return b; }
using PII = pair<int, int>;
using i128 = __int128;
//=======================================================================
const int N = 1e5 + 10;
const int M = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e16;
int n, m, T;
//=======================================================================
signed main() {
kuaidu();
cin >> T;
while (T--) {
int l1, l2, r1, r2;
cin >> l1 >> r1 >> l2 >> r2;
set<int> cnt[15];
set<int> cnt2[15];
rep(i, 0, 13) cnt[i].clear(), cnt2[i].clear();
int l = 0;
while (r1) {
int cha = r1 / 10 - l1 / 10;
if (cha >= 2) {
rep(i, 0, 9)
cnt[l].insert(i);
l++;
l1 /= 10, r1 /= 10;
continue;
}
int x = l1, y = r1;
rep(i, x, y) cnt[l].insert(i % 10);
l++;
l1 /= 10, r1 /= 10;
}
int len = l;
l = 0;
while (r2) {
int cha = r2 / 10 - l2 / 10;
if (cha >= 2) {
rep(i, 0, 9)
cnt2[l].insert(i);
l++;
l2 /= 10, r2 /= 10;
continue;
}
int x = l2, y = r2;
rep(i, x, y) cnt2[l].insert(i % 10);
l++;
l2 /= 10, r2 /= 10;
}
int ans = 0;
l = max(l, len);
rep(i, 0, l - 1) {
for (auto x : cnt[i]) for (auto y : cnt2[i]) {
ans = max(ans, ((x + y) % 10));
}
}
cout << ans << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
2 178 182 83 85 2 5 3 6
output:
7 9
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 3816kb
input:
1000 158260522 877914575 24979445 602436426 1 5 1101111 1101112 2 5 33333 33335 1 5 10111 10111 138996221 797829355 353195922 501899080 212 215 10302 10302 101100 101101 1 2 111 114 1101000 1101001 265804420 569328197 234828607 807497925 1110110 1110112 11100 11103 323 327 23 27 1 1 1 5 316412581 80...
output:
9 7 9 6 9 7 3 5 9 5 9 6 9 9 9 9 9 9 9 9 9 5 9 6 9 9 7 8 9 9 9 9 9 9 3 9 9 7 7 9 9 6 9 9 9 8 9 6 9 9 9 5 9 4 8 5 9 7 8 8 9 9 9 6 9 8 9 5 9 7 9 7 9 9 6 5 9 1 3 6 9 9 8 6 9 9 6 4 9 9 9 9 9 9 9 2 9 4 5 9 9 9 8 6 9 5 7 9 9 8 9 5 9 7 8 5 9 9 9 7 9 9 3 3 9 9 5 7 9 9 6 6 9 7 7 9 9 7 9 9 9 5 9 6 9 7 9 4 9 5 ...
result:
wrong answer 36th lines differ - expected: '8', found: '9'