QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226005#7581. Radar Scannerucup-team004#AC ✓195ms8748kbC++201.5kb2023-10-25 14:24:102023-10-25 14:24:12

Judging History

你现在查看的是最新测评结果

  • [2023-10-25 14:24:12]
  • 评测
  • 测评结果:AC
  • 用时:195ms
  • 内存:8748kb
  • [2023-10-25 14:24:10]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

constexpr int M = 1000;

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> x1(n), y1(n), x2(n), y2(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        x1[i]--, y1[i]--;
    }
    i64 ans = 0;
    for (int fx = 0; fx <= 1; fx++) {
        for (int fy = 0; fy <= 1; fy++) {
            std::vector a(M + 1, std::vector<int>(M + 1));
            for (int i = 0; i < n; i++) {
                a[x1[i]][y1[i]] += 1;
                a[x1[i]][y2[i] - fy] -= 1;
                a[x2[i] - fx][y1[i]] -= 1;
                a[x2[i] - fx][y2[i] - fy] += 1;
            }
            for (int i = 0; i <= M; i++) {
                for (int j = 1; j <= M; j++) {
                    a[i][j] += a[i][j - 1];
                }
            }
            for (int i = 1; i <= M; i++) {
                for (int j = 0; j <= M; j++) {
                    a[i][j] += a[i - 1][j];
                }
            }
            for (int i = 0; i < M; i++) {
                for (int j = 0; j < M; j++) {
                    ans += 1LL * a[i][j] * (a[i][j] - 1) * (a[i][j] - 2) / 6 * (fx ^ fy ? -1 : 1);
                }
            }
        }
    }
    std::cout << ans << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 17ms
memory: 7180kb

input:

2
3
3 1 3 1
1 1 2 3
2 1 3 2
5
1 1 4 5
2 1 3 2
2 2 3 3
4 5 4 5
1 2 2 4

output:

0
4

result:

ok 2 number(s): "0 4"

Test #2:

score: 0
Accepted
time: 195ms
memory: 8748kb

input:

10
5
2 1 3 3
1 5 1 5
1 2 2 3
4 1 5 3
1 2 4 4
10
3 3 7 5
3 4 3 4
5 4 6 6
8 1 10 6
6 1 9 8
2 6 8 10
3 2 8 7
5 1 5 8
2 2 7 7
1 1 2 3
100
1 37 28 37
1 5 6 40
9 29 47 30
12 9 12 9
40 14 45 14
13 28 16 34
44 8 46 47
23 9 40 42
13 1 35 17
9 31 46 31
1 10 34 48
5 35 46 50
16 21 28 49
3 6 3 24
5 3 39 28
30 8...

output:

1
31
16256
29932636832595
20948001862043
20395156087285
20094030388871
20143137954387
19922797032244
20114049116806

result:

ok 10 numbers