QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#686541 | #1958. Grid Triangle | xhytom | TL | 0ms | 3840kb | C++14 | 2.6kb | 2024-10-29 14:08:58 | 2024-10-29 14:08:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::vector<int> x(4);
for (int i = 1; i <= 3; i++) {
std::cin >> x[i];
}
std::sort(x.begin() + 1, x.end());
int a = x[1], b = x[2], c = x[2];
i64 ans = 0;
auto check = [&](int x, int y) {
return -y <= x && x <= y;
};
auto checkmi = [&](int lo, int x, int hi) {
return lo <= x && x <= hi;
};
auto getansxminusy = [&](int lo, int x, int hi) {
ans += hi - lo + 1;
if (lo <= 0 && 0 <= hi) {
ans --;
}
if (lo <= x && x <= hi) {
ans --;
}
if (lo <= -x && -x <= hi) {
ans --;
}
if (std::abs(x) % 2 == 0) {
if (lo <= x / 2 && x / 2 <= hi) {
ans --;
}
}
if (lo <= x * 2 && x * 2 <= hi) {
ans --;
}
};
auto getansxplusy = [&](int lo, int x, int hi) {
ans += hi - lo + 1;
if (lo <= 0 && 0 <= hi) {
ans --;
}
if (lo <= x && x <= hi) {
ans --;
}
if (lo <= -x && -x <= hi) {
ans --;
}
if (std::abs(x) % 2 == 0) {
if (lo <= -x / 2 && -x / 2 <= hi) {
ans --;
}
}
if (lo <= -x * 2 && -x * 2 <= hi) {
ans --;
}
};
for (int i = -a; i <= a; i++) {
if (i == 0) continue;
{ // x, y, x + y
// x + y, -x, y
if (check(i, b)) {
int hi = std::min(c, a - i);
int lo = std::max(-c, -a - i);
getansxplusy(lo, i, hi);
}
// -y, x + y, x
if (check(i, c)) {
int hi = std::min(a, b - i);
int lo = std::max(-a, -b - i);
getansxplusy(lo, i, hi);
}
}
{ // x, y, - x - y
// x + y, -x, -y
if (check(i, b)) {
int hi = std::min(c, a - i);
int lo = std::max(-c, -a - i);
getansxplusy(lo, i, hi);
}
// -y, x + y, -x
if (check(i, c)) {
int hi = std::min(a, b - i);
int lo = std::max(-a, -b - i);
getansxplusy(lo, i, hi);
}
}
{ // x, y, x - y
// x - y, x, -y
if (check(i, b)) {
int hi = std::min(c, a + i);
int lo = std::max(-c, -a + i);
getansxminusy(lo, i, hi);
}
// y, y - x, x
if (check(i, c)) {
int hi = std::min(a, b + i);
int lo = std::max(-a, -b + i);
getansxminusy(lo, i, hi);
}
}
{ // x, y, -x + y
// x - y, x, y
if (check(i, b)) {
int hi = std::min(c, a + i);
int lo = std::max(-c, -a + i);
getansxminusy(lo, i, hi);
}
// y, y - x, -x
if (check(i, c)) {
int hi = std::min(a, b + i);
int lo = std::max(-a, -b + i);
getansxminusy(lo, i, hi);
}
}
}
std::cout << ans / 2 << '\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3516kb
input:
1 1 4
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
1 1 5
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
1 2 6
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
1 2 7
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
2 2 8
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
2 3 9
output:
16
result:
ok single line: '16'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
2 3 10
output:
16
result:
ok single line: '16'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
2 3 11
output:
16
result:
ok single line: '16'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
3 4 12
output:
64
result:
ok single line: '64'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
3 4 13
output:
64
result:
ok single line: '64'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
3 4 14
output:
64
result:
ok single line: '64'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
3 5 15
output:
80
result:
ok single line: '80'
Test #13:
score: -100
Time Limit Exceeded
input:
10000000 10000000 10000000