QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#510440 | #9158. 分数 | nhuang685# | 5 | 1415ms | 189644kb | C++20 | 1.1kb | 2024-08-09 04:33:43 | 2024-08-09 04:33:44 |
Judging History
answer
#include <bits/stdc++.h>
constexpr int64_t MAXN = 3e7;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
// std::vector vis(std::max(n, m) + 1, std::vector<bool>(std::max(n, m) + 1));
std::unordered_set<int64_t> vis;
int64_t ans = 0;
auto next = [&](int a, int b) -> std::array<std::pair<int, int>, 2> {
// std::vector<std::pair<int, int>> nxt{{b, a}, {a + 2 * b, b}};
// if (a > 2 * b) {
// nxt.emplace_back(a - 2 * b, b);
// }
// return nxt;
return {std::pair{a + 2 * b, b}, std::pair{a, b + 2 * a}};
};
auto dfs = [&](auto &self, int a, int b) -> void {
if (1 <= a && a <= n && 1 <= b && b <= m) {
ans += 2;
}
for (auto [na, nb] : next(a, b)) {
int64_t val = MAXN * na + nb;
if (1 <= na && na <= std::max(n, m) && 1 <= nb && nb <= std::max(n, m) && !vis.contains(val)) {
vis.insert(val);
self(self, na, nb);
}
}
};
vis.insert(MAXN + 2);
dfs(dfs, 1, 2);
std::cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 5
Accepted
time: 0ms
memory: 3532kb
input:
99 99
output:
406
result:
ok 1 number(s): "406"
Pretest #2:
score: 0
Wrong Answer
time: 0ms
memory: 3784kb
input:
98 97
output:
404
result:
wrong answer 1st numbers differ - expected: '405', found: '404'
Pretest #3:
score: 0
Wrong Answer
time: 0ms
memory: 3816kb
input:
99 96
output:
404
result:
wrong answer 1st numbers differ - expected: '396', found: '404'
Pretest #4:
score: 0
Wrong Answer
time: 1ms
memory: 3908kb
input:
995 977
output:
11124
result:
wrong answer 1st numbers differ - expected: '11153', found: '11124'
Pretest #5:
score: 5
Accepted
time: 1ms
memory: 3832kb
input:
991 990
output:
11220
result:
ok 1 number(s): "11220"
Pretest #6:
score: 0
Wrong Answer
time: 1ms
memory: 3900kb
input:
976 968
output:
10894
result:
wrong answer 1st numbers differ - expected: '10900', found: '10894'
Pretest #7:
score: 0
Wrong Answer
time: 14ms
memory: 8324kb
input:
7602 7864
output:
215834
result:
wrong answer 1st numbers differ - expected: '215706', found: '215834'
Pretest #8:
score: 0
Wrong Answer
time: 9ms
memory: 8568kb
input:
7959 7735
output:
220200
result:
wrong answer 1st numbers differ - expected: '220256', found: '220200'
Pretest #9:
score: 0
Wrong Answer
time: 9ms
memory: 8248kb
input:
7878 7863
output:
221184
result:
wrong answer 1st numbers differ - expected: '221162', found: '221184'
Pretest #10:
score: 0
Wrong Answer
time: 10ms
memory: 8236kb
input:
7788 7658
output:
215292
result:
wrong answer 1st numbers differ - expected: '215323', found: '215292'
Pretest #11:
score: 0
Wrong Answer
time: 1378ms
memory: 189644kb
input:
95399 99767
output:
8286036
result:
wrong answer 1st numbers differ - expected: '8285295', found: '8286036'
Pretest #12:
score: 0
Wrong Answer
time: 1415ms
memory: 189384kb
input:
98051 99642
output:
8440068
result:
wrong answer 1st numbers differ - expected: '8439713', found: '8440068'
Pretest #13:
score: 0
Wrong Answer
time: 1283ms
memory: 182288kb
input:
95624 96007
output:
8067904
result:
wrong answer 1st numbers differ - expected: '8068127', found: '8067904'
Pretest #14:
score: 0
Wrong Answer
time: 1366ms
memory: 188588kb
input:
99208 98047
output:
8411838
result:
wrong answer 1st numbers differ - expected: '8412610', found: '8411838'
Pretest #15:
score: 0
Time Limit Exceeded
input:
997417 967722
output:
result:
Pretest #16:
score: 0
Time Limit Exceeded
input:
987807 956529
output:
result:
Pretest #17:
score: 0
Time Limit Exceeded
input:
971654 984345
output:
result:
Pretest #18:
score: 0
Time Limit Exceeded
input:
7892259 7983727
output:
result:
Pretest #19:
score: 0
Memory Limit Exceeded
input:
7937869 29796968
output:
result:
Pretest #20:
score: 0
Memory Limit Exceeded
input:
29717543 29510173
output:
result:
Final Tests
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3812kb
input:
96 98
output:
388
result:
wrong answer 1st numbers differ - expected: '396', found: '388'
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 3528kb
input:
100 99
output:
406
result:
wrong answer 1st numbers differ - expected: '408', found: '406'
Test #3:
score: 5
Accepted
time: 0ms
memory: 3552kb
input:
99 99
output:
406
result:
ok 1 number(s): "406"
Test #4:
score: 0
Wrong Answer
time: 1ms
memory: 3868kb
input:
963 951
output:
10660
result:
wrong answer 1st numbers differ - expected: '10634', found: '10660'
Test #5:
score: 0
Wrong Answer
time: 0ms
memory: 4064kb
input:
958 974
output:
10780
result:
wrong answer 1st numbers differ - expected: '10795', found: '10780'
Test #6:
score: 0
Wrong Answer
time: 1ms
memory: 3824kb
input:
966 990
output:
11026
result:
wrong answer 1st numbers differ - expected: '11003', found: '11026'
Test #7:
score: 0
Wrong Answer
time: 7ms
memory: 8644kb
input:
7958 7947
output:
224448
result:
wrong answer 1st numbers differ - expected: '224482', found: '224448'
Test #8:
score: 0
Wrong Answer
time: 9ms
memory: 8252kb
input:
7623 7730
output:
213406
result:
wrong answer 1st numbers differ - expected: '213444', found: '213406'
Test #9:
score: 0
Wrong Answer
time: 10ms
memory: 8396kb
input:
7845 7783
output:
218842
result:
wrong answer 1st numbers differ - expected: '218916', found: '218842'
Test #10:
score: 0
Wrong Answer
time: 10ms
memory: 8252kb
input:
7881 7773
output:
219362
result:
wrong answer 1st numbers differ - expected: '219451', found: '219362'
Test #11:
score: 0
Wrong Answer
time: 1401ms
memory: 188856kb
input:
99414 98698
output:
8464850
result:
wrong answer 1st numbers differ - expected: '8465217', found: '8464850'
Test #12:
score: 0
Wrong Answer
time: 1405ms
memory: 186444kb
input:
98249 96148
output:
8236732
result:
wrong answer 1st numbers differ - expected: '8237486', found: '8236732'
Test #13:
score: 0
Wrong Answer
time: 1339ms
memory: 188112kb
input:
99003 96832
output:
8323406
result:
wrong answer 1st numbers differ - expected: '8324931', found: '8323406'
Test #14:
score: 0
Wrong Answer
time: 1365ms
memory: 186780kb
input:
98266 96030
output:
8230174
result:
wrong answer 1st numbers differ - expected: '8231065', found: '8230174'
Test #15:
score: 0
Time Limit Exceeded
input:
968207 958885
output:
result:
Test #16:
score: 0
Time Limit Exceeded
input:
959846 998397
output:
result:
Test #17:
score: 0
Time Limit Exceeded
input:
965821 972280
output:
result:
Test #18:
score: 0
Time Limit Exceeded
input:
7855098 7962479
output:
result:
Test #19:
score: 0
Memory Limit Exceeded
input:
7841076 29648718
output:
result:
Test #20:
score: 0
Memory Limit Exceeded
input:
29365129 29012208