QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#301521 | #2731. Cartesian Conquest | Camillus | 0 | 17ms | 50432kb | C++20 | 1.7kb | 2024-01-10 00:46:44 | 2024-01-10 00:46:45 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
struct pair_hash {
size_t operator()(const pair<int, int> &p) const {
return p.first ^ p.second;
}
};
static constexpr int maxn = 1e8;
int fff(int n, int m) {
return (min(n, m) ^ 228) + (max(n, m) ^ 52);
}
int saved_mx[maxn];
int mx_func(int n, int m) {
if (n > m) {
swap(n, m);
}
if (saved_mx[fff(n, m)]) {
return saved_mx[fff(n, m)];
}
int cur = 0;
if (n % 2 == 0 && m - n / 2 > 0) {
cur = max(cur, mx_func(n, m - n / 2));
}
if (m % 2 == 0 && n - m / 2 > 0) {
cur = max(cur, mx_func(n - m / 2, m));
}
if (m - 2 * n > 0) {
cur = max(cur, mx_func(n, m - 2 * n));
}
if (n - 2 * m > 0) {
cur = max(cur, mx_func(n - 2 * m, m));
}
return saved_mx[fff(n, m)] = cur + 1;
}
int saved_mn[maxn];
int mn_func(int n, int m) {
if (n > m) {
swap(n, m);
}
if (saved_mn[fff(n, m)]) {
return saved_mn[fff(n, m)];
}
if (n == 2 * m || m == 2 * n) {
return 1;
}
int cur = INT32_MAX;
if (n % 2 == 0 && m - n / 2 > 0) {
cur = min(cur, mn_func(n, m - n / 2));
}
if (m % 2 == 0 && n - m / 2 > 0) {
cur = min(cur, mn_func(n - m / 2, m));
}
if (m - 2 * n > 0) {
cur = min(cur, mn_func(n, m - 2 * n));
}
if (n - 2 * m > 0) {
cur = min(cur, mn_func(n - 2 * m, m));
}
return saved_mn[fff(n, m)] = cur + 1;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
cout << mn_func(n, m) << ' ' << mx_func(n, m) << '\n';
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 0ms
memory: 3704kb
input:
2 1
output:
1 1
result:
ok single line: '1 1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
2 4
output:
1 4
result:
ok single line: '1 4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
5 4
output:
4 4
result:
ok single line: '4 4'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
4 6
output:
3 6
result:
ok single line: '3 6'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
1000 2
output:
250 1000
result:
ok single line: '250 1000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
1 1000
output:
500 500
result:
ok single line: '500 500'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
1000 1000
output:
2 8
result:
ok single line: '2 8'
Test #8:
score: -5
Wrong Answer
time: 0ms
memory: 3688kb
input:
872 976
output:
8 119
result:
wrong answer 1st lines differ - expected: '11 133', found: '8 119'
Subtask #2:
score: 0
Wrong Answer
Test #20:
score: 8
Accepted
time: 0ms
memory: 3740kb
input:
2 1001
output:
251 1001
result:
ok single line: '251 1001'
Test #21:
score: 0
Accepted
time: 17ms
memory: 50432kb
input:
1 1000000
output:
500000 500000
result:
ok single line: '500000 500000'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
1000000 1000000
output:
2 25
result:
ok single line: '2 25'
Test #23:
score: -8
Wrong Answer
time: 1ms
memory: 4140kb
input:
80400 64364
output:
17 662
result:
wrong answer 1st lines differ - expected: '18 622', found: '17 662'
Subtask #3:
score: 0
Runtime Error
Test #45:
score: 0
Runtime Error
input:
100000000 2